File size: 5,251 Bytes
dc2106c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// SPDX-License-Identifier: Apache-2.0


syntax = "proto2";

package {PACKAGE_NAME};
// #if ONNX-ML
import "onnx/onnx-ml.proto";
// #else
import "onnx/onnx.proto";
// #endif

// This file contains the proto definitions for MapProto and
// SequenceProto. These protos are used to represent the data structures
// of maps and sequence for use in test data or ModelProto.

// Sequences
//
// Defines a dense, ordered, collection of elements that are of homogeneous types.
// Sequences can be made out of tensors, maps, or sequences.
//
// If a sequence is made out of tensors, the tensors must have the same element
// type (i.e. int32). In some cases, the tensors in a sequence can have different
// shapes.  Whether the tensors can have different shapes or not depends on the
// type/shape associated with the corresponding "ValueInfo". For example,
// "Sequence<Tensor<float, [M,N]>" means that all tensors have same shape. However,
// "Sequence<Tensor<float, [omitted,omitted]>" means they can have different
// shapes (all of rank 2), where "omitted" means the corresponding dimension has
// no symbolic/constant value. Finally, "Sequence<Tensor<float, omitted>>" means
// that the different tensors can have different ranks, when the "shape" itself
// is omitted from the tensor-type. For a more complete description, refer to
// https://github.com/onnx/onnx/blob/main/docs/IR.md#static-tensor-shapes.
//
message SequenceProto {

  optional string name = 1;

  enum DataType {
    UNDEFINED = 0;
    TENSOR = 1;
    SPARSE_TENSOR = 2;
    SEQUENCE = 3;
    MAP = 4;
    OPTIONAL = 5;
  }

  // The data type of the element.
  // This field MUST have a valid SequenceProto.DataType value
  optional int32 elem_type = 2;

  // For TensorProto values.
  // When this field is present, the elem_type field MUST be TENSOR.
  repeated TensorProto tensor_values = 3;

  // For SparseTensorProto values.
  // When this field is present, the elem_type field MUST be SPARSE_TENSOR.
  repeated SparseTensorProto sparse_tensor_values = 4;

  // For SequenceProto values, allowing sequences to be of themselves.
  // When this field is present, the elem_type field MUST be SEQUENCE.
  repeated SequenceProto sequence_values = 5;

  // For MapProto values.
  // When this field is present, the elem_type field MUST be MAP.
  repeated MapProto map_values = 6;

  // For OptionalProto values.
  // When this field is present, the elem_type field MUST be Optional.
  repeated OptionalProto optional_values = 7;

}


// Maps
//
// Specifies an associative table, defined by keys and values.
// MapProto is formed with a repeated field of keys (of type INT8, INT16, INT32,
// INT64, UINT8, UINT16, UINT32, UINT64, or STRING) and values (of type TENSOR,
// SPARSE_TENSOR, SEQUENCE, or MAP). Key types and value types have to remain
// the same throughout the instantiation of the MapProto.
//
message MapProto {

  optional string name = 1;

  // All MapProto data types must have the same length of keys and values.

  // The data type of the key.
  // This field MUST have a valid TensorProto.DataType value of
  // INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, or STRING
  optional int32 key_type = 2;

  // Every element of keys has to be one of the following data types
  // INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, or STRING.
  // The integer cases are represented by the repeated int64 field keys below.
  repeated int64 keys = 3;

  // If keys are strings, they are represented by the repeated bytes field
  // string_keys below.
  repeated bytes string_keys = 4;

  // MapProto values are represented in a SequenceProto of the same length as the
  // repeated keys field and have to be one of the following data types
  // TENSOR, SPARSE_TENSOR, MAP, SEQUENCE.
  optional SequenceProto values = 5;
}

// Optional
//
//
message OptionalProto {

  optional string name = 1;

  enum DataType {
    UNDEFINED = 0;
    TENSOR = 1;
    SPARSE_TENSOR = 2;
    SEQUENCE = 3;
    MAP = 4;
    OPTIONAL = 5;
  }

  // The data type of the element, identifies if the OptionalProto value
  // is Tensor, Sparse Tensor, Sequence, Map, or Optional.
  // The type of the optional value MUST match the elem_type specified.
  // This field MUST have a valid OptionalProto.DataType value.
  optional int32 elem_type = 2;

  // For TensorProto value.
  // When this field is present, the elem_type field MUST be TENSOR.
  optional TensorProto tensor_value = 3;

  // For SparseTensorProto value.
  // When this field is present, the elem_type field MUST be SPARSE_TENSOR.
  optional SparseTensorProto sparse_tensor_value = 4;

  // For SequenceProto value.
  // When this field is present, the elem_type field MUST be SEQUENCE.
  optional SequenceProto sequence_value = 5;

  // For MapProto value.
  // When this field is present, the elem_type field MUST be MAP.
  optional MapProto map_value = 6;

  // For OptionalProto value, allowing optional to be of itself (completeness)
  // When this field is present, the elem_type field MUST be OPTIONAL.
  optional OptionalProto optional_value = 7;

}