From fc5875dcbcfe5da0eafbc2b4f73149c1fb9c4d6b Mon Sep 17 00:00:00 2001 From: wangyunkai <675680243@qq.com> Date: Mon, 25 Nov 2024 16:30:15 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8F=90=E4=BA=A4proto=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scalar/server/src/proto/histogram.proto | 26 ++ .../server/src/proto/mindspore_anf_ir.proto | 353 ++++++++++++++++++ .../server/src/proto/mindspore_summary.proto | 188 ++++++++++ .../server/src/proto/resource_handle.proto | 47 +++ .../Scalar/server/src/proto/summary.proto | 132 +++++++ .../Scalar/server/src/proto/tensor.proto | 101 +++++ .../server/src/proto/tensor_shape.proto | 47 +++ .../Scalar/server/src/proto/types.proto | 100 +++++ 8 files changed, 994 insertions(+) create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/histogram.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_anf_ir.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_summary.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/resource_handle.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/summary.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor_shape.proto create mode 100644 plugins/mindstudio-insight-plugins/Scalar/server/src/proto/types.proto diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/histogram.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/histogram.proto new file mode 100644 index 000000000..568a90b73 --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/histogram.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package tensorboard; + +option cc_enable_arenas = true; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/google/tsl/tsl/go/core/protobuf/summary_go_proto"; + +// Serialization format for histogram module in +// tsl/lib/histogram/histogram.h +message HistogramProto { + double min = 1; + double max = 2; + double num = 3; + double sum = 4; + double sum_squares = 5; + + // Parallel arrays encoding the bucket boundaries and the bucket values. + // bucket(i) is the count for the bucket i. The range for + // a bucket is: + // i == 0: -DBL_MAX .. bucket_limit(0) + // i != 0: bucket_limit(i-1) .. bucket_limit(i) + repeated double bucket_limit = 6 [packed = true]; + repeated double bucket = 7 [packed = true]; +} diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_anf_ir.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_anf_ir.proto new file mode 100644 index 000000000..f221e6d7f --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_anf_ir.proto @@ -0,0 +1,353 @@ +/** + * Copyright 2019 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +package mindspore.irpb; + + +// Versioning +enum Version { + // unknown version + UNKNOWWN_VERSION = 0; + + // Initial version (IR VERSION 1), published on Sep 23, 2019 + IR_VERSION = 0x0000000000000001; +} + +// Data type definition +enum DataType { + DT_UNDEFINED = 0; + // Basic types. + DT_BOOL = 1; // bool + + DT_INT8 = 2; // int8_t + DT_INT16 = 3; // int16_t + DT_INT32 = 4; // int32_t + DT_INT64 = 5; // int64_t + + DT_UINT8 = 6; // uint8_t + DT_UINT16 = 7; // uint16_t + DT_UINT32 = 8; // uint32_t + DT_UINT64 = 9; // uint64_t + + DT_FLOAT16 = 10; // float 16 + DT_FLOAT32 = 11; // float 32 + DT_FLOAT64 = 12; // float 64 + + DT_STRING = 13; // string + DT_TENSOR = 14; // tensor + DT_GRAPH = 15; // graph + + // list type + DT_BOOLS = 16; // list of bool + + DT_INTS8 = 17; // list of int8_t + DT_INTS16 = 18; // list of int16_t + DT_INTS32 = 19; // list of int32_t + DT_INTS64 = 20; // list of int64_t + + DT_UINTS8 = 21; // list of uint8_t + DT_UINTS16 = 22; // list of uint16_t + DT_UINTS32 = 23; // list of uint32_t + DT_UINTS64 = 24; // list of uint64_t + + DT_FLOATS16 = 25; // list of float16 + DT_FLOATS32 = 26; // list of float32 + DT_FLOATS64 = 27; // list of float64 + + DT_STRINGS = 28; // list of string + DT_TENSORS = 29; // list of tensor + DT_GRAPHS = 30; // list of graph + + DT_TUPLE = 31; // tuple + DT_LIST = 32; // list + DT_DICT = 33; // dictionary + + // other types + DT_NONE = 34; // None + DT_SYM_INST = 35; // Symbolic Key Instance + + // type related type + DT_BASE_INT = 36; // type generic int + DT_BASE_UINT = 37; // type generate unsigned int + DT_BASE_FLOAT = 38; // type generate float + DT_TYPE = 39; // type type + DT_ANY = 40; // type any + DT_REFKEY = 41; // type refkey + DT_REF = 42; // type ref + DT_COMPLEX64 = 43; // list of complex64 + DT_COMPLEX128 = 44; // list of complex128 + DT_BASE_COMPLEX = 45; // type generate complex + + // bfloat type + DT_BFLOAT16 = 46; // bfloat16 + DT_BFLOATS16 = 47; // list of bfloat16 + + // quant type + DT_INT4 = 48; // int4 + + // slice type + DT_SLICE = 49; +} + +// Value definition for attribute value or parameter default value +message ValueProto { + // data type of value + optional DataType dtype = 1; // discriminator that indicates which field below is in use + + // Exactly ONE of the following fields must be present for this version of the IR + optional bool bool_val = 2; // bool + optional int64 int_val = 3; // int + optional uint64 uint_val = 4; // uint + optional float float_val = 5; // float + optional double double_val = 6; // double + optional string str_val = 7; // string + optional TensorProto tensor_val = 8; // tensor value + optional GraphProto graph = 9; // graph + + repeated bool bool_vals = 10; // list of bool + repeated int64 int_vals = 11; // list of int + repeated uint64 uint_vals = 12; // list of uint + repeated float float_vals = 13; // list of float + repeated double double_vals = 14; // list of double + repeated string str_vals = 15; // list of string + repeated TensorProto tensor_vals = 16; // list of tensor value + repeated GraphProto graphs = 17; // list of graph + + // tuple or list + repeated ValueProto values = 18; // tuple, list of value + + // dictionary + repeated NamedValueProto dict_val = 19; // dictionary info + + // filed for type type + optional TypeProto type_val = 20; // type type info +} + +message AttributeProto { + optional string name = 1; // attribute name + optional ValueProto value = 2; // attribute value +} + +message NamedValueProto { + optional string key = 1; // attribute name + optional ValueProto value = 2; // attribute value +} + +// Defines a tensor shape. +message TensorShapeProto { + // One dimension of the tensor. + message Dimension { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). + optional int64 size = 1; + + // Optional name of the tensor dimension. + optional string name = 2; + }; + + repeated Dimension dim = 1; +} + +// Types for graph input(parameter) and output +message TypeProto { + + message Tensor { + // This field MUST have a valid DataType value except DT_TENSOR + optional DataType elem_type = 1; + optional TensorShapeProto shape = 2; // for scalar, this field is not set + } + + // tuple type + message Sequence { + // The type and optional shape of elements of the tuple. + repeated TypeProto elem_types = 1; + }; + + // data type + optional DataType data_type = 1; + + oneof value { + // The type of a tensor. + Tensor tensor_type = 2; + + // The type of a tuple. + Sequence sequence_type = 3; + } +} + +// Defines information on graph parameters, including the name, the type, and +// the default value of parameter if exists. +message ParameterProto { + optional string name = 1; // parameter name + optional TypeProto type = 2; // parameter type + optional ValueProto default_val = 3; // default value of parameter if exists +} + +// Defines graph output information +message OutputProto { + optional string name = 1; // output node name + optional TypeProto type = 2; // output node type +} + +// Define node input information +message InputProto { + enum EdgeType { + DATA_EDGE = 0; // data edge + CONTROL_EDGE = 1; // control edge + } + + optional string name = 1; + optional EdgeType type = 2; +} + +// Nodes +// +// Computation graphs are made up of a DAG of nodes, which represent what is +// commonly called a "layer" or "pipeline stage" in machine learning frameworks. +// +// For example, it can be a node of type "Conv" that takes in an image, a filter +// tensor and a bias tensor, and produces the convolved output. +message NodeProto { + repeated InputProto input = 1; // namespace Value + optional string name = 2; // namespace Value + + // The symbolic identifier of the Operator to execute. + optional string op_type = 3; // namespace Operator + // The domain of the OperatorSet that specifies the operator named by op_type. + optional string scope = 4; // namespace Domain + + // Additional named attributes. + repeated AttributeProto attribute = 5; + + // Optional type info of this node + optional TypeProto output_type = 6; + + // other fields for debug + optional uint64 output_i = 7; + + // The full_name_with_scope of CNode + optional string full_name = 8; + + // Note: Id 9 is reserved for the source_address field of the debugger, please see debug_graph.proto + + // As same as the IR file instance name field. + optional string instance_name = 10; +} + +// Models +// +// ModelProto is a top-level file/container format for bundling a ML model and +// associating its computation graph with metadata. +// +// The semantics of the model are described by the associated GraphProto. +message ModelProto { + // ir version + optional int64 ir_version = 1; + + // Domain name of the model. + // We use reverse domain names as name space indicators. For example: + // `com.facebook.fair` or `com.microsoft.cognitiveservices` + // + // Together with `model_version` and GraphProto.name, this forms the unique identity of + // the graph. + optional string domain = 2; + + // The version of the graph encoded. See Version enum below. + optional int64 model_version = 3; + + // The parameterized graph that is evaluated to execute the model. + optional GraphProto graph = 4; + + // metadata info of operators + optional OperatorSetProto metadata_operators = 5; +}; + +message OperatorProto { + optional string name = 1; // used as key, must be distinct + optional bytes config = 2; // operator config info + optional bytes obj_info = 3; // operator related object info, e.g. content of operator binary or name +}; + +message OperatorSetProto { + repeated OperatorProto operators = 1; + optional string summary = 2; // summary info of operators, e.g. file position of operators file +} + +// Graphs +// +// A graph defines the computational logic of a model and is comprised of a parameterized +// list of nodes that form a directed acyclic graph based on their inputs and outputs. +// This is the equivalent of the "network" or "graph" in many deep learning +// frameworks. +message GraphProto { + // The nodes in the graph, sorted topologically. + repeated NodeProto node = 1; + + // The name of the graph. + optional string name = 2; // namespace Graph + + // The parameters(inputs) and outputs of the graph. + repeated ParameterProto parameters = 3; + repeated OutputProto outputs = 4; + + // Constants used in this graph + repeated NamedValueProto const_vals = 5; +} + +// Tensors +// +// A serialized tensor value. +message TensorProto { + // The shape of the tensor. + repeated int64 dims = 1; + + // The data type of the tensor. + // This field MUST have a valid DataType value except DT_TENSOR + optional DataType data_type = 2; + + // Tensor content must be organized in row-major order. + // + // Depending on the data_type field, exactly one of the fields below with + // name ending in _data is used to store the elements of the tensor. + + // For float values + repeated float float_data = 3 [packed = true]; + + // For int32, uint8, int8, uint16, int16, and bool values + // When this field is present, the data_type field MUST be + // INT32, INT16, INT8, UINT16, UINT8, or BOOL + repeated int32 int32_data = 4 [packed = true]; + + // For int64. + // When this field is present, the data_type field MUST be INT64 + repeated int64 int64_data = 5 [packed = true]; + + // For double + // When this field is present, the data_type field MUST be DOUBLE + repeated double double_data = 6 [packed = true]; + + // For uint64 and uint32 values + // When this field is present, the data_type field MUST be + // UINT32 or UINT64 + repeated uint64 uint64_data = 7 [packed = true]; + + // Store raw tensor content. When this raw_data field is used to store tensor value, + // elements MUST be stored in as fixed-width, little-endian order. + optional bytes raw_data = 8; +} diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_summary.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_summary.proto new file mode 100644 index 000000000..b9c67279d --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/mindspore_summary.proto @@ -0,0 +1,188 @@ +/** + * Copyright 2019-2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; + +package mindspore.irpb; +option cc_enable_arenas = true; + +// The ANF IR define, include the tensor and graph define +import "mindspore_anf_ir.proto"; + +// Event Protocol buffer, Top define +message Event { + // Timestamp + required double wall_time = 1; + + // The step of train. + optional int64 step = 2; + + oneof what { + // An event file was started, with the specified version. + // Now version is "MindSpore.Event:1" + string version = 3; + + // GraphDef. + GraphProto graph_def = 4; + + // Summary data + Summary summary = 5; + + Explain explain = 6; + } +} + +message LossLandscape{ + message Point { + optional TensorProto x = 1; + optional TensorProto y = 2; + optional TensorProto z = 3; + } + + message LossPath { + repeated int32 intervals = 1; // step intervals or epoch intervals + optional Point points = 2; + } + + message Metadata { + optional string decomposition = 1; + optional string unit = 2; // step or epoch + optional int32 step_per_epoch = 3; + } + + optional Point landscape = 1; + optional LossPath loss_path = 2; + optional Metadata metadata = 3; // maybe only record by the first value + optional Point convergence_point = 4; + +} + +// A Summary is a set of named values that be produced regularly during training +message Summary { + message Image { + // Dimensions of the image. + required int32 height = 1; + required int32 width = 2; + // Valid colorspace values are: + // 1 - grayscale type + // 2 - grayscale + alpha type + // 3 - RGB type + // 4 - RGBA type + // 5 - DIGITAL_YUV type + // 6 - BGRA type + required int32 colorspace = 3; + // Image data in encoded format. Now only support the RGB. + required bytes encoded_image = 4; + } + + message Histogram { + message bucket{ + // Count number of values fallen in [left, left + width). + // For the right most bucket, range is [left, left + width]. + required double left = 1; + required double width = 2; + required int64 count = 3; + } + + repeated bucket buckets = 1; + optional int64 nan_count = 2; + optional int64 pos_inf_count = 3; + optional int64 neg_inf_count = 4; + + // max, min, sum will not take nan and inf into account. + // If there is no valid value in tensor, max will be nan, min will be nan, sum will be 0. + optional double max = 5; + optional double min = 6; + optional double sum = 7; + + // total number of values, including nan and inf + optional int64 count = 8; + } + + message Value { + // Tag name for the data. + required string tag = 1; + + // Value associated with the tag. + oneof value { + float scalar_value = 3; + Image image = 4; + TensorProto tensor = 8; + Histogram histogram = 9; + LossLandscape loss_landscape = 10; + } + } + + // Set of values for the summary. + repeated Value value = 1; +} + +message Explain { + message Inference{ + repeated float ground_truth_prob = 1; + repeated int32 predicted_label = 2; + repeated float predicted_prob = 3; + repeated float ground_truth_prob_sd = 4; + repeated float ground_truth_prob_itl95_low = 5; + repeated float ground_truth_prob_itl95_hi = 6; + repeated float predicted_prob_sd = 7; + repeated float predicted_prob_itl95_low = 8; + repeated float predicted_prob_itl95_hi = 9; + } + + message Explanation{ + optional string explain_method = 1; + optional int32 label = 2; + optional string heatmap_path = 3; + } + + message Benchmark{ + optional string benchmark_method = 1; + optional string explain_method = 2; + optional float total_score = 3; + repeated float label_score = 4; + } + + message Metadata{ + repeated string label = 1; + repeated string explain_method = 2; + repeated string benchmark_method = 3; + } + + message HocLayer { + optional float prob = 1; + repeated int32 box = 2; // List of repeated x, y, w, h + } + + message Hoc { + optional int32 label = 1; + optional string mask = 2; + repeated HocLayer layer = 3; + } + + optional int32 sample_id = 1; + optional string image_path = 2; // The Metadata and image path must have one fill in + repeated int32 ground_truth_label = 3; + + optional Inference inference = 4; + repeated Explanation explanation = 5; + repeated Benchmark benchmark = 6; + + optional Metadata metadata = 7; + optional string status = 8; // enum value: run, end + + repeated Hoc hoc = 9; // hierarchical occlusion counterfactual +} \ No newline at end of file diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/resource_handle.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/resource_handle.proto new file mode 100644 index 000000000..084a11cc6 --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/resource_handle.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package tensorboard; + +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "ResourceHandle"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/resource_handle_go_proto"; + +// Protocol buffer representing a handle to a tensorflow resource. Handles are +// not valid across executions, but can be serialized back and forth from within +// a single run. +message ResourceHandleProto { + // Unique name for the device containing the resource. + string device = 1; + + // Container in which this resource is placed. + string container = 2; + + // Unique name of this resource. + string name = 3; + + // Hash code for the type of the resource. Is only valid in the same device + // and in the same execution. + uint64 hash_code = 4; + + // For debug-only, the name of the type pointed to by this handle, if + // available. + string maybe_type_name = 5; + + // Protocol buffer representing a pair of (data type, tensor shape). + message DtypeAndShape { + // Data type of the tensor. + DataType dtype = 1; + // Shape of the tensor. + TensorShapeProto shape = 2; + } + + // Data types and shapes for the underlying resource. + repeated DtypeAndShape dtypes_and_shapes = 6; + + reserved 7; +} diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/summary.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/summary.proto new file mode 100644 index 000000000..734d5e936 --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/summary.proto @@ -0,0 +1,132 @@ +syntax = "proto3"; + +package tensorboard; + +import public "histogram.proto"; +import "tensor.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "SummaryProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/summary_go_proto"; + +// Metadata associated with a series of Summary data +message SummaryDescription { + // Hint on how plugins should process the data in this series. + // Supported values include "scalar", "histogram", "image", "audio" + string type_hint = 1; +} + +// A SummaryMetadata encapsulates information on 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; + + // The content to store for the plugin. The best practice is for this to be + // a binary serialized protocol buffer. + bytes content = 2; + } + + // Data that associates a summary with a certain plugin. + PluginData plugin_data = 1; + + // Display name for viewing in TensorBoard. + string display_name = 2; + + // Longform readable description of the summary sequence. Markdown supported. + string summary_description = 3; + + // Class of data stored in this time series. Required for compatibility with + // TensorBoard's generic data facilities (`DataProvider`, et al.). This value + // imposes constraints on the dtype and shape of the corresponding tensor + // values. See `DataClass` docs for details. + DataClass data_class = 4; +} + +enum DataClass { + // Unknown data class, used (implicitly) for legacy data. Will not be + // processed by data ingestion pipelines. + DATA_CLASS_UNKNOWN = 0; + // Scalar time series. Each `Value` for the corresponding tag must have + // `tensor` set to a rank-0 tensor of type `DT_FLOAT` (float32). + DATA_CLASS_SCALAR = 1; + // Tensor time series. Each `Value` for the corresponding tag must have + // `tensor` set. The tensor value is arbitrary, but should be small to + // accommodate direct storage in database backends: an upper bound of a few + // kilobytes is a reasonable rule of thumb. + DATA_CLASS_TENSOR = 2; + // Blob sequence time series. Each `Value` for the corresponding tag must + // have `tensor` set to a rank-1 tensor of bytestring dtype. + DATA_CLASS_BLOB_SEQUENCE = 3; +} + +// A Summary is a set of named values to be displayed by the +// visualizer. +// +// Summaries are produced regularly during training, as controlled by +// the "summary_interval_secs" attribute of the training operation. +// Summaries are also produced at the end of an evaluation. +message Summary { + message Image { + // Dimensions of the image. + int32 height = 1; + int32 width = 2; + // Valid colorspace values are + // 1 - grayscale + // 2 - grayscale + alpha + // 3 - RGB + // 4 - RGBA + // 5 - DIGITAL_YUV + // 6 - BGRA + int32 colorspace = 3; + // Image data in encoded format. All image formats supported by + // image_codec::CoderUtil can be stored here. + bytes encoded_image_string = 4; + } + + message Audio { + // Sample rate of the audio in Hz. + float sample_rate = 1; + // Number of channels of audio. + int64 num_channels = 2; + // Length of the audio in frames (samples per channel). + int64 length_frames = 3; + // Encoded audio data and its associated RFC 2045 content type (e.g. + // "audio/wav"). + bytes encoded_audio_string = 4; + string content_type = 5; + } + + message Value { + // This field is deprecated and will not be set. + string node_name = 7; + + // Tag name for the data. Used by TensorBoard plugins to organize data. Tags + // are often organized by scope (which contains slashes to convey + // hierarchy). For example: foo/bar/0 + string tag = 1; + + // Contains metadata on the summary value such as which plugins may use it. + // Take note that many summary values may lack a metadata field. This is + // because the FileWriter only keeps a metadata object on the first summary + // value with a certain tag for each tag. TensorBoard then remembers which + // tags are associated with which plugins. This saves space. + SummaryMetadata metadata = 9; + + // Value associated with the tag. + oneof value { + float simple_value = 2; + bytes obsolete_old_style_histogram = 3; + Image image = 4; + HistogramProto histo = 5; + Audio audio = 6; + TensorProto tensor = 8; + } + } + + // Set of values for the summary. + repeated Value value = 1; +} diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor.proto new file mode 100644 index 000000000..251ac2b6b --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; + +package tensorboard; + +import "resource_handle.proto"; +import "tensor_shape.proto"; +import "types.proto"; + +option cc_enable_arenas = true; +option java_outer_classname = "TensorProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_go_proto"; + +// Protocol buffer representing a tensor. +message TensorProto { + // Data type of the tensor. + DataType dtype = 1; + + // Shape of the tensor. TODO(touts): sort out the 0-rank issues. + TensorShapeProto tensor_shape = 2; + + // Only one of the representations below is set, one of "tensor_contents" and + // the "xxx_val" attributes. We are not using oneof because as oneofs cannot + // contain repeated fields it would require another extra set of messages. + + // Version number. + // + // In version 0, if the "repeated xxx" representations contain only one + // element, that element is repeated to fill the shape. This makes it easy + // to represent a constant Tensor with a single value. + int32 version_number = 3; + + // Serialized raw tensor content from either Tensor::AsProtoTensorContent or + // memcpy in tensorflow::grpc::EncodeTensorToByteBuffer. This representation + // can be used for all tensor types. The purpose of this representation is to + // reduce serialization overhead during RPC call by avoiding serialization of + // many repeated small items. + bytes tensor_content = 4; + + // Type specific representations that make it easy to create tensor protos in + // all languages. Only the representation corresponding to "dtype" can + // be set. The values hold the flattened representation of the tensor in + // row major order. + + // DT_HALF, DT_BFLOAT16. Note that since protobuf has no int16 type, we'll + // have some pointless zero padding for each value here. + repeated int32 half_val = 13 [packed = true]; + + // DT_FLOAT. + repeated float float_val = 5 [packed = true]; + + // DT_DOUBLE. + repeated double double_val = 6 [packed = true]; + + // DT_INT32, DT_INT16, DT_UINT16, DT_INT8, DT_UINT8. + repeated int32 int_val = 7 [packed = true]; + + // DT_STRING + repeated bytes string_val = 8; + + // DT_COMPLEX64. scomplex_val(2*i) and scomplex_val(2*i+1) are real + // and imaginary parts of i-th single precision complex. + repeated float scomplex_val = 9 [packed = true]; + + // DT_INT64 + repeated int64 int64_val = 10 [packed = true]; + + // DT_BOOL + repeated bool bool_val = 11 [packed = true]; + + // DT_COMPLEX128. dcomplex_val(2*i) and dcomplex_val(2*i+1) are real + // and imaginary parts of i-th double precision complex. + repeated double dcomplex_val = 12 [packed = true]; + + // DT_RESOURCE + repeated ResourceHandleProto resource_handle_val = 14; + + // DT_VARIANT + repeated VariantTensorDataProto variant_val = 15; + + // DT_UINT32 + repeated uint32 uint32_val = 16 [packed = true]; + + // DT_UINT64 + repeated uint64 uint64_val = 17 [packed = true]; + + // DT_FLOAT8_*, use variable-sized set of bytes + // (i.e. the equivalent of repeated uint8, if such a thing existed). + bytes float8_val = 18; +} + +// Protocol buffer representing the serialization format of DT_VARIANT tensors. +message VariantTensorDataProto { + // Name of the type of objects being serialized. + string type_name = 1; + // Portions of the object that are not Tensors. + bytes metadata = 2; + // Tensors contained within objects being serialized. + repeated TensorProto tensors = 3; +} diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor_shape.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor_shape.proto new file mode 100644 index 000000000..9da8a082b --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/tensor_shape.proto @@ -0,0 +1,47 @@ +// Protocol buffer representing the shape of tensors. + +syntax = "proto3"; + +option cc_enable_arenas = true; +option java_outer_classname = "TensorShapeProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/tensor_shape_go_proto"; + +package tensorboard; + +// Dimensions of a tensor. +message TensorShapeProto { + // One dimension of the tensor. + message Dim { + // Size of the tensor in that dimension. + // This value must be >= -1, but values of -1 are reserved for "unknown" + // shapes (values of -1 mean "unknown" dimension). Certain wrappers + // that work with TensorShapeProto may fail at runtime when deserializing + // a TensorShapeProto containing a dim value of -1. + int64 size = 1; + + // Optional name of the tensor dimension. + string name = 2; + }; + + // Dimensions of the tensor, such as {"input", 30}, {"output", 40} + // for a 30 x 40 2D tensor. If an entry has size -1, this + // corresponds to a dimension of unknown size. The names are + // optional. + // + // The order of entries in "dim" matters: It indicates the layout of the + // values in the tensor in-memory representation. + // + // The first entry in "dim" is the outermost dimension used to layout the + // values, the last entry is the innermost dimension. This matches the + // in-memory layout of RowMajor Eigen tensors. + // + // If "dim.size()" > 0, "unknown_rank" must be false. + repeated Dim dim = 2; + + // If true, the number of dimensions in the shape is unknown. + // + // If true, "dim.size()" must be 0. + bool unknown_rank = 3; +}; diff --git a/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/types.proto b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/types.proto new file mode 100644 index 000000000..89d541141 --- /dev/null +++ b/plugins/mindstudio-insight-plugins/Scalar/server/src/proto/types.proto @@ -0,0 +1,100 @@ +syntax = "proto3"; + +package tensorboard; + +option cc_enable_arenas = true; +option java_outer_classname = "TypesProtos"; +option java_multiple_files = true; +option java_package = "org.tensorflow.framework"; +option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/framework/types_go_proto"; + +// (== suppress_warning documentation-presence ==) +// DISABLED.IfChange +enum DataType { + // Not a legal value for DataType. Used to indicate a DataType field + // has not been set. + DT_INVALID = 0; + + // Data types that all computation devices are expected to be + // capable to support. + DT_FLOAT = 1; + DT_DOUBLE = 2; + DT_INT32 = 3; + DT_UINT8 = 4; + DT_INT16 = 5; + DT_INT8 = 6; + DT_STRING = 7; + DT_COMPLEX64 = 8; // Single-precision complex + DT_INT64 = 9; + DT_BOOL = 10; + DT_QINT8 = 11; // Quantized int8 + DT_QUINT8 = 12; // Quantized uint8 + DT_QINT32 = 13; // Quantized int32 + DT_BFLOAT16 = 14; // Float32 truncated to 16 bits. + DT_QINT16 = 15; // Quantized int16 + DT_QUINT16 = 16; // Quantized uint16 + DT_UINT16 = 17; + DT_COMPLEX128 = 18; // Double-precision complex + DT_HALF = 19; + DT_RESOURCE = 20; + DT_VARIANT = 21; // Arbitrary C++ data types + DT_UINT32 = 22; + DT_UINT64 = 23; + DT_FLOAT8_E5M2 = 24; // 5 exponent bits, 2 mantissa bits. + DT_FLOAT8_E4M3FN = 25; // 4 exponent bits, 3 mantissa bits, finite-only, with + // 2 NaNs (0bS1111111). + // TODO - b/299182407: Leaving room for remaining float8 types. + // DT_FLOAT8_E4M3FNUZ = 26; + // DT_FLOAT8_E4M3B11FNUZ = 27; + // DT_FLOAT8_E5M2FNUZ = 28; + DT_INT4 = 29; + DT_UINT4 = 30; + + // Do not use! These are only for TF1's obsolete reference Variables. + // Every enum above should have a corresponding value below (verified by + // types_test). + DT_FLOAT_REF = 101; + DT_DOUBLE_REF = 102; + DT_INT32_REF = 103; + DT_UINT8_REF = 104; + DT_INT16_REF = 105; + DT_INT8_REF = 106; + DT_STRING_REF = 107; + DT_COMPLEX64_REF = 108; + DT_INT64_REF = 109; + DT_BOOL_REF = 110; + DT_QINT8_REF = 111; + DT_QUINT8_REF = 112; + DT_QINT32_REF = 113; + DT_BFLOAT16_REF = 114; + DT_QINT16_REF = 115; + DT_QUINT16_REF = 116; + DT_UINT16_REF = 117; + DT_COMPLEX128_REF = 118; + DT_HALF_REF = 119; + DT_RESOURCE_REF = 120; + DT_VARIANT_REF = 121; + DT_UINT32_REF = 122; + DT_UINT64_REF = 123; + DT_FLOAT8_E5M2_REF = 124; + DT_FLOAT8_E4M3FN_REF = 125; + // TODO - b/299182407: Leaving room for remaining float8 types. + // DT_FLOAT8_E4M3FNUZ_REF = 126; + // DT_FLOAT8_E4M3B11FNUZ_REF = 127; + // DT_FLOAT8_E5M2FNUZ_REF = 128; + DT_INT4_REF = 129; + DT_UINT4_REF = 130; +} +// DISABLED.ThenChange( +// https://www.tensorflow.org/code/tensorflow/c/tf_datatype.h, +// https://www.tensorflow.org/code/tensorflow/go/tensor.go, +// https://www.tensorflow.org/code/tensorboard/compat/proto/tensor.cc, +// https://www.tensorflow.org/code/tensorboard/compat/proto/types.h, +// https://www.tensorflow.org/code/tensorboard/compat/proto/types.cc, +// https://www.tensorflow.org/code/tensorboard/compat/proto/dtypes.py, +// https://www.tensorflow.org/code/tensorboard/compat/proto/function.py) + +// Represents a serialized tf.dtypes.Dtype +message SerializedDType { + DataType datatype = 1; +} -- Gitee