Elffuss BraidHub

kikocis/ncnn public

pnnx ci for torch 2.4 (#5618)

* update onnx proto
Changesete82546bbc24a01714e0c07908f86fce86286ed085b0cb37b3b96a77f01e076d1
Authornihui <nihuini@tencent.com> · 2024-08-10 11:39 +08:00
CommitterGitHub <noreply@github.com> · 2024-08-10 11:39 +08:00
Parentsdc9c921ccdf6

Browse the files at this changeset

37 files changed

modified .ci/pnnx.yml +8 −5
@@ -17,10 +17,10 @@
1717
1818 variables:
1919 protobuf_version: 21.12
20- libtorch_version: 2.3.0
21- libtorchvision_version: 0.18.0
22- onnxruntime_version: 1.17.3
23- cache_date: 20240504
20+ libtorch_version: 2.4.0
21+ libtorchvision_version: 0.19.0
22+ onnxruntime_version: 1.18.1
23+ cache_date: 20240804
2424
2525 jobs:
2626 ubuntu:
@@ -57,6 +57,9 @@
5757 - torch-version: 2.3.0
5858 torchvision-version: 0.18.0
5959
60+ - torch-version: 2.4.0
61+ torchvision-version: 0.19.0
62+
6063 runs-on:
6164 pool-name: docker
6265 container:
@@ -160,7 +163,7 @@
160163 - name: setup-pytorch
161164 run: |
162165 export PYTHONUSERBASE=${{ci.workspace}}/torch-${{matrix.torch-version}}
163- pip3 install --user torch==${{matrix.torch-version}}+cpu torchvision==${{matrix.torchvision-version}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
166+ pip3 install --user torch==${{matrix.torch-version}}+cpu torchvision==${{matrix.torchvision-version}}+cpu --index-url https://download.pytorch.org/whl/cpu
164167 pip3 install --user onnx
165168 pip3 install --user onnxscript
166169
modified tools/pnnx/src/CMakeLists.txt +2 −2
@@ -587,12 +587,12 @@
587587 endif()
588588
589589 if(Protobuf_FOUND OR protobuf_MODULE_COMPATIBLE)
590- protobuf_generate_cpp(ONNX_PROTO_SRCS ONNX_PROTO_HDRS onnx.proto)
590+ protobuf_generate_cpp(ONNX_PROTO_SRCS ONNX_PROTO_HDRS onnx-data.proto onnx-ml.proto onnx-operators-ml.proto)
591591 add_library(onnxproto STATIC ${ONNX_PROTO_SRCS} ${ONNX_PROTO_HDRS})
592592 target_include_directories(onnxproto PUBLIC ${PROTOBUF_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
593593 target_link_libraries(onnxproto PUBLIC ${PROTOBUF_LIBRARIES})
594594 else()
595- add_library(onnxproto STATIC onnx.proto)
595+ add_library(onnxproto STATIC onnx-data.proto onnx-ml.proto onnx-operators-ml.proto)
596596 target_include_directories(onnxproto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
597597 protobuf_generate(TARGET onnxproto)
598598 target_link_libraries(onnxproto PUBLIC protobuf::libprotobuf)
modified tools/pnnx/src/load_onnx.cpp +1 −1
@@ -14,7 +14,7 @@
1414
1515 #include "load_onnx.h"
1616
17-#include "onnx.pb.h"
17+#include "onnx-ml.pb.h"
1818
1919 #include <google/protobuf/io/coded_stream.h>
2020 #include <google/protobuf/io/zero_copy_stream_impl.h>
added tools/pnnx/src/onnx-data.proto +155 −0
@@ -0,0 +1,155 @@
1+//
2+// WARNING: This file is automatically generated! Please edit onnx.in.proto.
3+//
4+
5+
6+// SPDX-License-Identifier: Apache-2.0
7+
8+
9+syntax = "proto2";
10+
11+package onnx;
12+import "onnx-ml.proto";
13+
14+// This file contains the proto definitions for MapProto and
15+// SequenceProto. These protos are used to represent the data structures
16+// of maps and sequence for use in test data or ModelProto.
17+
18+// Sequences
19+//
20+// Defines a dense, ordered, collection of elements that are of homogeneous types.
21+// Sequences can be made out of tensors, maps, or sequences.
22+//
23+// If a sequence is made out of tensors, the tensors must have the same element
24+// type (i.e. int32). In some cases, the tensors in a sequence can have different
25+// shapes. Whether the tensors can have different shapes or not depends on the
26+// type/shape associated with the corresponding "ValueInfo". For example,
27+// "Sequence<Tensor<float, [M,N]>" means that all tensors have same shape. However,
28+// "Sequence<Tensor<float, [omitted,omitted]>" means they can have different
29+// shapes (all of rank 2), where "omitted" means the corresponding dimension has
30+// no symbolic/constant value. Finally, "Sequence<Tensor<float, omitted>>" means
31+// that the different tensors can have different ranks, when the "shape" itself
32+// is omitted from the tensor-type. For a more complete description, refer to
33+// https://github.com/onnx/onnx/blob/main/docs/IR.md#static-tensor-shapes.
34+//
35+message SequenceProto {
36+
37+ optional string name = 1;
38+
39+ enum DataType {
40+ UNDEFINED = 0;
41+ TENSOR = 1;
42+ SPARSE_TENSOR = 2;
43+ SEQUENCE = 3;
44+ MAP = 4;
45+ OPTIONAL = 5;
46+ }
47+
48+ // The data type of the element.
49+ // This field MUST have a valid SequenceProto.DataType value
50+ optional int32 elem_type = 2;
51+
52+ // For TensorProto values.
53+ // When this field is present, the elem_type field MUST be TENSOR.
54+ repeated TensorProto tensor_values = 3;
55+
56+ // For SparseTensorProto values.
57+ // When this field is present, the elem_type field MUST be SPARSE_TENSOR.
58+ repeated SparseTensorProto sparse_tensor_values = 4;
59+
60+ // For SequenceProto values, allowing sequences to be of themselves.
61+ // When this field is present, the elem_type field MUST be SEQUENCE.
62+ repeated SequenceProto sequence_values = 5;
63+
64+ // For MapProto values.
65+ // When this field is present, the elem_type field MUST be MAP.
66+ repeated MapProto map_values = 6;
67+
68+ // For OptionalProto values.
69+ // When this field is present, the elem_type field MUST be Optional.
70+ repeated OptionalProto optional_values = 7;
71+
72+}
73+
74+
75+// Maps
76+//
77+// Specifies an associative table, defined by keys and values.
78+// MapProto is formed with a repeated field of keys (of type INT8, INT16, INT32,
79+// INT64, UINT8, UINT16, UINT32, UINT64, or STRING) and values (of type TENSOR,
80+// SPARSE_TENSOR, SEQUENCE, or MAP). Key types and value types have to remain
81+// the same throughout the instantiation of the MapProto.
82+//
83+message MapProto {
84+
85+ optional string name = 1;
86+
87+ // All MapProto data types must have the same length of keys and values.
88+
89+ // The data type of the key.
90+ // This field MUST have a valid TensorProto.DataType value of
91+ // INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, or STRING
92+ optional int32 key_type = 2;
93+
94+ // Every element of keys has to be one of the following data types
95+ // INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, or STRING.
96+ // The integer cases are represented by the repeated int64 field keys below.
97+ repeated int64 keys = 3;
98+
99+ // If keys are strings, they are represented by the repeated bytes field
100+ // string_keys below.
101+ repeated bytes string_keys = 4;
102+
103+ // MapProto values are represented in a SequenceProto of the same length as the
104+ // repeated keys field and have to be one of the following data types
105+ // TENSOR, SPARSE_TENSOR, MAP, SEQUENCE.
106+ optional SequenceProto values = 5;
107+}
108+
109+// Optional
110+//
111+//
112+message OptionalProto {
113+
114+ optional string name = 1;
115+
116+ enum DataType {
117+ UNDEFINED = 0;
118+ TENSOR = 1;
119+ SPARSE_TENSOR = 2;
120+ SEQUENCE = 3;
121+ MAP = 4;
122+ OPTIONAL = 5;
123+ }
124+
125+ // The data type of the element, identifies if the OptionalProto value
126+ // is Tensor, Sparse Tensor, Sequence, Map, or Optional.
127+ // The type of the optional value MUST match the elem_type specified.
128+ // This field MUST have a valid OptionalProto.DataType value.
129+ optional int32 elem_type = 2;
130+
131+ // For TensorProto value.
132+ // When this field is present, the elem_type field MUST be TENSOR.
133+ optional TensorProto tensor_value = 3;
134+
135+ // For SparseTensorProto value.
136+ // When this field is present, the elem_type field MUST be SPARSE_TENSOR.
137+ optional SparseTensorProto sparse_tensor_value = 4;
138+
139+ // For SequenceProto value.
140+ // When this field is present, the elem_type field MUST be SEQUENCE.
141+ optional SequenceProto sequence_value = 5;
142+
143+ // For MapProto value.
144+ // When this field is present, the elem_type field MUST be MAP.
145+ optional MapProto map_value = 6;
146+
147+ // For OptionalProto value, allowing optional to be of itself (completeness)
148+ // When this field is present, the elem_type field MUST be OPTIONAL.
149+ optional OptionalProto optional_value = 7;
150+
151+}
152+
153+// For using protobuf-lite
154+option optimize_for = LITE_RUNTIME;
155+
added tools/pnnx/src/onnx-ml.proto +888 −0
@@ -0,0 +1,888 @@
1+//
2+// WARNING: This file is automatically generated! Please edit onnx.in.proto.
3+//
4+
5+
6+// SPDX-License-Identifier: Apache-2.0
7+
8+
9+syntax = "proto2";
10+
11+package onnx;
12+
13+// Overview
14+//
15+// ONNX is an open specification that is comprised of the following components:
16+//
17+// 1) A definition of an extensible computation graph model.
18+// 2) Definitions of standard data types.
19+// 3) Definitions of built-in operators.
20+//
21+// This document describes the syntax of models and their computation graphs,
22+// as well as the standard data types. Together, they are referred to as the ONNX
23+// Intermediate Representation, or 'IR' for short.
24+//
25+// The normative semantic specification of the ONNX IR is found in docs/IR.md.
26+// Definitions of the built-in neural network operators may be found in docs/Operators.md.
27+// Definitions of the built-in classical machine learning operators may be found in
28+// docs/Operators-ml.md.
29+
30+// Notes
31+//
32+// Protobuf compatibility
33+//
34+// To simplify framework compatibility, ONNX is defined using the subset of protobuf
35+// that is compatible with both protobuf v2 and v3. This means that we do not use any
36+// protobuf features that are only available in one of the two versions.
37+//
38+// Here are the most notable contortions we have to carry out to work around
39+// these limitations:
40+//
41+// - No 'map' (added protobuf 3.0). We instead represent mappings as lists
42+// of key-value pairs, where order does not matter and duplicates
43+// are not allowed.
44+
45+
46+// Versioning
47+//
48+// ONNX versioning is specified in docs/IR.md and elaborated on in docs/Versioning.md
49+//
50+// To be compatible with both proto2 and proto3, we will use a version number
51+// that is not defined by the default value but an explicit enum number.
52+enum Version {
53+ // proto3 requires the first enum value to be zero.
54+ // We add this just to appease the compiler.
55+ _START_VERSION = 0;
56+ // The version field is always serialized and we will use it to store the
57+ // version that the graph is generated from. This helps us set up version
58+ // control.
59+ // For the IR, we are using simple numbers starting with 0x00000001,
60+ // which was the version we published on Oct 10, 2017.
61+ IR_VERSION_2017_10_10 = 0x0000000000000001;
62+
63+ // IR_VERSION 2 published on Oct 30, 2017
64+ // - Added type discriminator to AttributeProto to support proto3 users
65+ IR_VERSION_2017_10_30 = 0x0000000000000002;
66+
67+ // IR VERSION 3 published on Nov 3, 2017
68+ // - For operator versioning:
69+ // - Added new message OperatorSetIdProto
70+ // - Added opset_import in ModelProto
71+ // - For vendor extensions, added domain in NodeProto
72+ IR_VERSION_2017_11_3 = 0x0000000000000003;
73+
74+ // IR VERSION 4 published on Jan 22, 2019
75+ // - Relax constraint that initializers should be a subset of graph inputs
76+ // - Add type BFLOAT16
77+ IR_VERSION_2019_1_22 = 0x0000000000000004;
78+
79+ // IR VERSION 5 published on March 18, 2019
80+ // - Add message TensorAnnotation.
81+ // - Add quantization annotation in GraphProto to map tensor with its scale and zero point quantization parameters.
82+ IR_VERSION_2019_3_18 = 0x0000000000000005;
83+
84+ // IR VERSION 6 published on Sep 19, 2019
85+ // - Add support for sparse tensor constants stored in model.
86+ // - Add message SparseTensorProto
87+ // - Add sparse initializers
88+ IR_VERSION_2019_9_19 = 0x0000000000000006;
89+
90+ // IR VERSION 7 published on May 8, 2020
91+ // - Add support to allow function body graph to rely on multiple external opreator sets.
92+ // - Add a list to promote inference graph's initializers to global and
93+ // mutable variables. Global variables are visible in all graphs of the
94+ // stored models.
95+ // - Add message TrainingInfoProto to store initialization
96+ // method and training algorithm. The execution of TrainingInfoProto
97+ // can modify the values of mutable variables.
98+ // - Implicitly add inference graph into each TrainingInfoProto's algorithm.
99+ IR_VERSION_2020_5_8 = 0x0000000000000007;
100+
101+ // IR VERSION 8 published on July 30, 2021
102+ // Introduce TypeProto.SparseTensor
103+ // Introduce TypeProto.Optional
104+ // Added a list of FunctionProtos local to the model
105+ // Deprecated since_version and operator status from FunctionProto
106+ IR_VERSION_2021_7_30 = 0x0000000000000008;
107+
108+ // IR VERSION 9 published on May 5, 2023
109+ // Added AttributeProto to FunctionProto so that default attribute values can be set.
110+ // Added FLOAT8E4M3FN, FLOAT8E4M3FNUZ, FLOAT8E5M2, FLOAT8E5M2FNUZ.
111+ IR_VERSION_2023_5_5 = 0x0000000000000009;
112+
113+ // IR VERSION 10 published on TBD
114+ // Added UINT4, INT4.
115+ IR_VERSION = 0x000000000000000A;
116+}
117+
118+// Attributes
119+//
120+// A named attribute containing either singular float, integer, string, graph,
121+// and tensor values, or repeated float, integer, string, graph, and tensor values.
122+// An AttributeProto MUST contain the name field, and *only one* of the
123+// following content fields, effectively enforcing a C/C++ union equivalent.
124+message AttributeProto {
125+ reserved 12, 16 to 19;
126+ reserved "v";
127+
128+ // Note: this enum is structurally identical to the OpSchema::AttrType
129+ // enum defined in schema.h. If you rev one, you likely need to rev the other.
130+ enum AttributeType {
131+ UNDEFINED = 0;
132+ FLOAT = 1;
133+ INT = 2;
134+ STRING = 3;
135+ TENSOR = 4;
136+ GRAPH = 5;
137+ SPARSE_TENSOR = 11;
138+ TYPE_PROTO = 13;
139+
140+ FLOATS = 6;
141+ INTS = 7;
142+ STRINGS = 8;
143+ TENSORS = 9;
144+ GRAPHS = 10;
145+ SPARSE_TENSORS = 12;
146+ TYPE_PROTOS = 14;
147+ }
148+
149+ // The name field MUST be present for this version of the IR.
150+ optional string name = 1; // namespace Attribute
151+
152+ // if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
153+ // In this case, this AttributeProto does not contain data, and it's a reference of attribute
154+ // in parent scope.
155+ // NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
156+ optional string ref_attr_name = 21;
157+
158+ // A human-readable documentation for this attribute. Markdown is allowed.
159+ optional string doc_string = 13;
160+
161+ // The type field MUST be present for this version of the IR.
162+ // For 0.0.1 versions of the IR, this field was not defined, and
163+ // implementations needed to use has_field heuristics to determine
164+ // which value field was in use. For IR_VERSION 0.0.2 or later, this
165+ // field MUST be set and match the f|i|s|t|... field in use. This
166+ // change was made to accommodate proto3 implementations.
167+ optional AttributeType type = 20; // discriminator that indicates which field below is in use
168+
169+ // Exactly ONE of the following fields must be present for this version of the IR
170+ optional float f = 2; // float
171+ optional int64 i = 3; // int
172+ optional bytes s = 4; // UTF-8 string
173+ optional TensorProto t = 5; // tensor value
174+ optional GraphProto g = 6; // graph
175+ optional SparseTensorProto sparse_tensor = 22; // sparse tensor value
176+ // Do not use field below, it's deprecated.
177+ // optional ValueProto v = 12; // value - subsumes everything but graph
178+ optional TypeProto tp = 14; // type proto
179+
180+ repeated float floats = 7; // list of floats
181+ repeated int64 ints = 8; // list of ints
182+ repeated bytes strings = 9; // list of UTF-8 strings
183+ repeated TensorProto tensors = 10; // list of tensors
184+ repeated GraphProto graphs = 11; // list of graph
185+ repeated SparseTensorProto sparse_tensors = 23; // list of sparse tensors
186+ repeated TypeProto type_protos = 15;// list of type protos
187+}
188+
189+// Defines information on value, including the name, the type, and
190+// the shape of the value.
191+message ValueInfoProto {
192+ // This field MUST be present in this version of the IR.
193+ optional string name = 1; // namespace Value
194+ // This field MUST be present in this version of the IR for
195+ // inputs and outputs of the top-level graph.
196+ optional TypeProto type = 2;
197+ // A human-readable documentation for this value. Markdown is allowed.
198+ optional string doc_string = 3;
199+ // Named metadata values; keys should be distinct.
200+ repeated StringStringEntryProto metadata_props = 4;
201+}
202+
203+// Nodes
204+//
205+// Computation graphs are made up of a DAG of nodes, which represent what is
206+// commonly called a "layer" or "pipeline stage" in machine learning frameworks.
207+//
208+// For example, it can be a node of type "Conv" that takes in an image, a filter
209+// tensor and a bias tensor, and produces the convolved output.
210+message NodeProto {
211+ repeated string input = 1; // namespace Value
212+ repeated string output = 2; // namespace Value
213+
214+ // An optional identifier for this node in a graph.
215+ // This field MAY be absent in ths version of the IR.
216+ optional string name = 3; // namespace Node
217+
218+ // The symbolic identifier of the Operator to execute.
219+ optional string op_type = 4; // namespace Operator
220+ // The domain of the OperatorSet that specifies the operator named by op_type.
221+ optional string domain = 7; // namespace Domain
222+ // Overload identifier, used only to map this to a model-local function.
223+ optional string overload = 8;
224+
225+ // Additional named attributes.
226+ repeated AttributeProto attribute = 5;
227+
228+ // A human-readable documentation for this node. Markdown is allowed.
229+ optional string doc_string = 6;
230+
231+ // Named metadata values; keys should be distinct.
232+ repeated StringStringEntryProto metadata_props = 9;
233+}
234+
235+// Training information
236+// TrainingInfoProto stores information for training a model.
237+// In particular, this defines two functionalities: an initialization-step
238+// and a training-algorithm-step. Initialization resets the model
239+// back to its original state as if no training has been performed.
240+// Training algorithm improves the model based on input data.
241+//
242+// The semantics of the initialization-step is that the initializers
243+// in ModelProto.graph and in TrainingInfoProto.algorithm are first
244+// initialized as specified by the initializers in the graph, and then
245+// updated by the "initialization_binding" in every instance in
246+// ModelProto.training_info.
247+//
248+// The field "algorithm" defines a computation graph which represents a
249+// training algorithm's step. After the execution of a
250+// TrainingInfoProto.algorithm, the initializers specified by "update_binding"
251+// may be immediately updated. If the targeted training algorithm contains
252+// consecutive update steps (such as block coordinate descent methods),
253+// the user needs to create a TrainingInfoProto for each step.
254+message TrainingInfoProto {
255+ // This field describes a graph to compute the initial tensors
256+ // upon starting the training process. Initialization graph has no input
257+ // and can have multiple outputs. Usually, trainable tensors in neural
258+ // networks are randomly initialized. To achieve that, for each tensor,
259+ // the user can put a random number operator such as RandomNormal or
260+ // RandomUniform in TrainingInfoProto.initialization.node and assign its
261+ // random output to the specific tensor using "initialization_binding".
262+ // This graph can also set the initializers in "algorithm" in the same
263+ // TrainingInfoProto; a use case is resetting the number of training
264+ // iteration to zero.
265+ //
266+ // By default, this field is an empty graph and its evaluation does not
267+ // produce any output. Thus, no initializer would be changed by default.
268+ optional GraphProto initialization = 1;
269+
270+ // This field represents a training algorithm step. Given required inputs,
271+ // it computes outputs to update initializers in its own or inference graph's
272+ // initializer lists. In general, this field contains loss node, gradient node,
273+ // optimizer node, increment of iteration count.
274+ //
275+ // An execution of the training algorithm step is performed by executing the
276+ // graph obtained by combining the inference graph (namely "ModelProto.graph")
277+ // and the "algorithm" graph. That is, the actual
278+ // input/initializer/output/node/value_info/sparse_initializer list of
279+ // the training graph is the concatenation of
280+ // "ModelProto.graph.input/initializer/output/node/value_info/sparse_initializer"
281+ // and "algorithm.input/initializer/output/node/value_info/sparse_initializer"
282+ // in that order. This combined graph must satisfy the normal ONNX conditions.
283+ // Now, let's provide a visualization of graph combination for clarity.
284+ // Let the inference graph (i.e., "ModelProto.graph") be
285+ // tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d
286+ // and the "algorithm" graph be
287+ // tensor_d -> Add -> tensor_e
288+ // The combination process results
289+ // tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d -> Add -> tensor_e
290+ //
291+ // Notice that an input of a node in the "algorithm" graph may reference the
292+ // output of a node in the inference graph (but not the other way round). Also, inference
293+ // node cannot reference inputs of "algorithm". With these restrictions, inference graph
294+ // can always be run independently without training information.
295+ //
296+ // By default, this field is an empty graph and its evaluation does not
297+ // produce any output. Evaluating the default training step never
298+ // update any initializers.
299+ optional GraphProto algorithm = 2;
300+
301+ // This field specifies the bindings from the outputs of "initialization" to
302+ // some initializers in "ModelProto.graph.initializer" and
303+ // the "algorithm.initializer" in the same TrainingInfoProto.
304+ // See "update_binding" below for details.
305+ //
306+ // By default, this field is empty and no initializer would be changed
307+ // by the execution of "initialization".
308+ repeated StringStringEntryProto initialization_binding = 3;
309+
310+ // Gradient-based training is usually an iterative procedure. In one gradient
311+ // descent iteration, we apply
312+ //
313+ // x = x - r * g
314+ //
315+ // where "x" is the optimized tensor, "r" stands for learning rate, and "g" is
316+ // gradient of "x" with respect to a chosen loss. To avoid adding assignments
317+ // into the training graph, we split the update equation into
318+ //
319+ // y = x - r * g
320+ // x = y
321+ //
322+ // The user needs to save "y = x - r * g" into TrainingInfoProto.algorithm. To
323+ // tell that "y" should be assigned to "x", the field "update_binding" may
324+ // contain a key-value pair of strings, "x" (key of StringStringEntryProto)
325+ // and "y" (value of StringStringEntryProto).
326+ // For a neural network with multiple trainable (mutable) tensors, there can
327+ // be multiple key-value pairs in "update_binding".
328+ //
329+ // The initializers appears as keys in "update_binding" are considered
330+ // mutable variables. This implies some behaviors
331+ // as described below.
332+ //
333+ // 1. We have only unique keys in all "update_binding"s so that two
334+ // variables may not have the same name. This ensures that one
335+ // variable is assigned up to once.
336+ // 2. The keys must appear in names of "ModelProto.graph.initializer" or
337+ // "TrainingInfoProto.algorithm.initializer".
338+ // 3. The values must be output names of "algorithm" or "ModelProto.graph.output".
339+ // 4. Mutable variables are initialized to the value specified by the
340+ // corresponding initializer, and then potentially updated by
341+ // "initializer_binding"s and "update_binding"s in "TrainingInfoProto"s.
342+ //
343+ // This field usually contains names of trainable tensors
344+ // (in ModelProto.graph), optimizer states such as momentums in advanced
345+ // stochastic gradient methods (in TrainingInfoProto.graph),
346+ // and number of training iterations (in TrainingInfoProto.graph).
347+ //
348+ // By default, this field is empty and no initializer would be changed
349+ // by the execution of "algorithm".
350+ repeated StringStringEntryProto update_binding = 4;
351+}
352+
353+// Models
354+//
355+// ModelProto is a top-level file/container format for bundling a ML model and
356+// associating its computation graph with metadata.
357+//
358+// The semantics of the model are described by the associated GraphProto's.
359+message ModelProto {
360+ // The version of the IR this model targets. See Version enum above.
361+ // This field MUST be present.
362+ optional int64 ir_version = 1;
363+
364+ // The OperatorSets this model relies on.
365+ // All ModelProtos MUST have at least one entry that
366+ // specifies which version of the ONNX OperatorSet is
367+ // being imported.
368+ //
369+ // All nodes in the ModelProto's graph will bind against the operator
370+ // with the same-domain/same-op_type operator with the HIGHEST version
371+ // in the referenced operator sets.
372+ repeated OperatorSetIdProto opset_import = 8;
373+
374+ // The name of the framework or tool used to generate this model.
375+ // This field SHOULD be present to indicate which implementation/tool/framework
376+ // emitted the model.
377+ optional string producer_name = 2;
378+
379+ // The version of the framework or tool used to generate this model.
380+ // This field SHOULD be present to indicate which implementation/tool/framework
381+ // emitted the model.
382+ optional string producer_version = 3;
383+
384+ // Domain name of the model.
385+ // We use reverse domain names as name space indicators. For example:
386+ // `com.facebook.fair` or `com.microsoft.cognitiveservices`
387+ //
388+ // Together with `model_version` and GraphProto.name, this forms the unique identity of
389+ // the graph.
390+ optional string domain = 4;
391+
392+ // The version of the graph encoded. See Version enum below.
393+ optional int64 model_version = 5;
394+
395+ // A human-readable documentation for this model. Markdown is allowed.
396+ optional string doc_string = 6;
397+
398+ // The parameterized graph that is evaluated to execute the model.
399+ optional GraphProto graph = 7;
400+
401+ // Named metadata values; keys should be distinct.
402+ repeated StringStringEntryProto metadata_props = 14;
403+
404+ // Training-specific information. Sequentially executing all stored
405+ // `TrainingInfoProto.algorithm`s and assigning their outputs following
406+ // the corresponding `TrainingInfoProto.update_binding`s is one training
407+ // iteration. Similarly, to initialize the model
408+ // (as if training hasn't happened), the user should sequentially execute
409+ // all stored `TrainingInfoProto.initialization`s and assigns their outputs
410+ // using `TrainingInfoProto.initialization_binding`s.
411+ //
412+ // If this field is empty, the training behavior of the model is undefined.
413+ repeated TrainingInfoProto training_info = 20;
414+
415+ // A list of function protos local to the model.
416+ //
417+ // The (domain, name, overload) tuple must be unique across the function protos in this list.
418+ // In case of any conflicts the behavior (whether the model local functions are given higher priority,
419+ // or standard operator sets are given higher priotity or this is treated as error) is defined by
420+ // the runtimes.
421+ //
422+ // The operator sets imported by FunctionProto should be compatible with the ones
423+ // imported by ModelProto and other model local FunctionProtos.
424+ // Example, if same operator set say 'A' is imported by a FunctionProto and ModelProto
425+ // or by 2 FunctionProtos then versions for the operator set may be different but,
426+ // the operator schema returned for op_type, domain, version combination
427+ // for both the versions should be same for every node in the function body.
428+ //
429+ // One FunctionProto can reference other FunctionProto in the model, however, recursive reference
430+ // is not allowed.
431+ repeated FunctionProto functions = 25;
432+};
433+
434+// StringStringEntryProto follows the pattern for cross-proto-version maps.
435+// See https://developers.google.com/protocol-buffers/docs/proto3#maps
436+message StringStringEntryProto {
437+ optional string key = 1;
438+ optional string value = 2;
439+};
440+
441+message TensorAnnotation {
442+ optional string tensor_name = 1;
443+ // <key, value> pairs to annotate tensor specified by <tensor_name> above.
444+ // The keys used in the mapping below must be pre-defined in ONNX spec.
445+ // For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
446+ // quantization parameter keys.
447+ repeated StringStringEntryProto quant_parameter_tensor_names = 2;
448+}
449+
450+
451+
452+// Graphs
453+//
454+// A graph defines the computational logic of a model and is comprised of a parameterized
455+// list of nodes that form a directed acyclic graph based on their inputs and outputs.
456+// This is the equivalent of the "network" or "graph" in many deep learning
457+// frameworks.
458+message GraphProto {
459+ // The nodes in the graph, sorted topologically.
460+ repeated NodeProto node = 1;
461+
462+ // The name of the graph.
463+ optional string name = 2; // namespace Graph
464+
465+ // A list of named tensor values, used to specify constant inputs of the graph.
466+ // Each initializer (both TensorProto as well SparseTensorProto) MUST have a name.
467+ // The name MUST be unique across both initializer and sparse_initializer,
468+ // but the name MAY also appear in the input list.
469+ repeated TensorProto initializer = 5;
470+
471+ // Initializers (see above) stored in sparse format.
472+ repeated SparseTensorProto sparse_initializer = 15;
473+
474+ // A human-readable documentation for this graph. Markdown is allowed.
475+ optional string doc_string = 10;
476+
477+ // The inputs and outputs of the graph.
478+ repeated ValueInfoProto input = 11;
479+ repeated ValueInfoProto output = 12;
480+
481+ // Information for the values in the graph. The ValueInfoProto.name's
482+ // must be distinct. It is optional for a value to appear in value_info list.
483+ repeated ValueInfoProto value_info = 13;
484+
485+ // This field carries information to indicate the mapping among a tensor and its
486+ // quantization parameter tensors. For example:
487+ // For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
488+ // which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
489+ repeated TensorAnnotation quantization_annotation = 14;
490+
491+ // Named metadata values; keys should be distinct.
492+ repeated StringStringEntryProto metadata_props = 16;
493+
494+ reserved 3, 4, 6 to 9;
495+ reserved "ir_version", "producer_version", "producer_tag", "domain";
496+}
497+
498+// Tensors
499+//
500+// A serialized tensor value.
501+message TensorProto {
502+ enum DataType {
503+ UNDEFINED = 0;
504+ // Basic types.
505+ FLOAT = 1; // float
506+ UINT8 = 2; // uint8_t
507+ INT8 = 3; // int8_t
508+ UINT16 = 4; // uint16_t
509+ INT16 = 5; // int16_t
510+ INT32 = 6; // int32_t
511+ INT64 = 7; // int64_t
512+ STRING = 8; // string
513+ BOOL = 9; // bool
514+
515+ // IEEE754 half-precision floating-point format (16 bits wide).
516+ // This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
517+ FLOAT16 = 10;
518+
519+ DOUBLE = 11;
520+ UINT32 = 12;
521+ UINT64 = 13;
522+ COMPLEX64 = 14; // complex with float32 real and imaginary components
523+ COMPLEX128 = 15; // complex with float64 real and imaginary components
524+
525+ // Non-IEEE floating-point format based on IEEE754 single-precision
526+ // floating-point number truncated to 16 bits.
527+ // This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
528+ BFLOAT16 = 16;
529+
530+ // Non-IEEE floating-point format based on papers
531+ // FP8 Formats for Deep Learning, https://arxiv.org/abs/2209.05433,
532+ // 8-bit Numerical Formats For Deep Neural Networks, https://arxiv.org/pdf/2206.02915.pdf.
533+ // Operators supported FP8 are Cast, CastLike, QuantizeLinear, DequantizeLinear.
534+ // The computation usually happens inside a block quantize / dequantize
535+ // fused by the runtime.
536+ FLOAT8E4M3FN = 17; // float 8, mostly used for coefficients, supports nan, not inf
537+ FLOAT8E4M3FNUZ = 18; // float 8, mostly used for coefficients, supports nan, not inf, no negative zero
538+ FLOAT8E5M2 = 19; // follows IEEE 754, supports nan, inf, mostly used for gradients
539+ FLOAT8E5M2FNUZ = 20; // follows IEEE 754, supports nan, not inf, mostly used for gradients, no negative zero
540+
541+ // 4-bit data-types
542+ UINT4 = 21; // Unsigned integer in range [0, 15]
543+ INT4 = 22; // Signed integer in range [-8, 7], using two's-complement representation
544+
545+ // Future extensions go here.
546+ }
547+
548+ // The shape of the tensor.
549+ repeated int64 dims = 1;
550+
551+ // The data type of the tensor.
552+ // This field MUST have a valid TensorProto.DataType value
553+ optional int32 data_type = 2;
554+
555+ // For very large tensors, we may want to store them in chunks, in which
556+ // case the following fields will specify the segment that is stored in
557+ // the current TensorProto.
558+ message Segment {
559+ optional int64 begin = 1;
560+ optional int64 end = 2;
561+ }
562+ optional Segment segment = 3;
563+
564+ // Tensor content must be organized in row-major order.
565+ //
566+ // Depending on the data_type field, exactly one of the fields below with
567+ // name ending in _data is used to store the elements of the tensor.
568+
569+ // For float and complex64 values
570+ // Complex64 tensors are encoded as a single array of floats,
571+ // with the real components appearing in odd numbered positions,
572+ // and the corresponding imaginary component appearing in the
573+ // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
574+ // is encoded as [1.0, 2.0 ,3.0 ,4.0]
575+ // When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
576+ repeated float float_data = 4 [packed = true];
577+
578+ // For int32, uint8, int8, uint16, int16, uint4, int4, bool, float8 and float16 values
579+ // float16 and float8 values must be bit-wise converted to an uint16_t prior
580+ // to writing to the buffer.
581+ // uint4 and int4 values must be packed to 4bitx2 prior to writing to the buffer, the first element is stored in
582+ // the 4 LSB and the second element is stored in the 4 MSB.
583+ // When this field is present, the data_type field MUST be
584+ // INT32, INT16, INT8, INT4, UINT16, UINT8, UINT4, BOOL, FLOAT16, BFLOAT16, FLOAT8E4M3FN, FLOAT8E4M3FNUZ, FLOAT8E5M2, FLOAT8E5M2FNUZ
585+ repeated int32 int32_data = 5 [packed = true];
586+
587+ // For strings.
588+ // Each element of string_data is a UTF-8 encoded Unicode
589+ // string. No trailing null, no leading BOM. The protobuf "string"
590+ // scalar type is not used to match ML community conventions.
591+ // When this field is present, the data_type field MUST be STRING
592+ repeated bytes string_data = 6;
593+
594+ // For int64.
595+ // When this field is present, the data_type field MUST be INT64
596+ repeated int64 int64_data = 7 [packed = true];
597+
598+ // Optionally, a name for the tensor.
599+ optional string name = 8; // namespace Value
600+
601+ // A human-readable documentation for this tensor. Markdown is allowed.
602+ optional string doc_string = 12;
603+
604+ // Serializations can either use one of the fields above, or use this
605+ // raw bytes field. The only exception is the string case, where one is
606+ // required to store the content in the repeated bytes string_data field.
607+ //
608+ // When this raw_data field is used to store tensor value, elements MUST
609+ // be stored in as fixed-width, little-endian order.
610+ // Floating-point data types MUST be stored in IEEE 754 format.
611+ // Complex64 elements must be written as two consecutive FLOAT values, real component first.
612+ // Complex128 elements must be written as two consecutive DOUBLE values, real component first.
613+ // Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
614+ // uint4 and int4 values must be packed to 4bitx2, the first element is stored in the 4 LSB and the second element is stored in the 4 MSB.
615+ //
616+ // Note: the advantage of specific field rather than the raw_data field is
617+ // that in some cases (e.g. int data), protobuf does a better packing via
618+ // variable length storage, and may lead to smaller binary footprint.
619+ // When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
620+ optional bytes raw_data = 9;
621+
622+ // Data can be stored inside the protobuf file using type-specific fields or raw_data.
623+ // Alternatively, raw bytes data can be stored in an external file, using the external_data field.
624+ // external_data stores key-value pairs describing data location. Recognized keys are:
625+ // - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
626+ // protobuf model was stored
627+ // - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
628+ // Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
629+ // - "length" (optional) - number of bytes containing data. Integer stored as string.
630+ // - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
631+ repeated StringStringEntryProto external_data = 13;
632+
633+ // Location of the data for this tensor. MUST be one of:
634+ // - DEFAULT - data stored inside the protobuf message. Data is stored in raw_data (if set) otherwise in type-specified field.
635+ // - EXTERNAL - data stored in an external location as described by external_data field.
636+ enum DataLocation {
637+ DEFAULT = 0;
638+ EXTERNAL = 1;
639+ }
640+
641+ // If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
642+ optional DataLocation data_location = 14;
643+
644+ // For double
645+ // Complex128 tensors are encoded as a single array of doubles,
646+ // with the real components appearing in odd numbered positions,
647+ // and the corresponding imaginary component appearing in the
648+ // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
649+ // is encoded as [1.0, 2.0 ,3.0 ,4.0]
650+ // When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
651+ repeated double double_data = 10 [packed = true];
652+
653+ // For uint64 and uint32 values
654+ // When this field is present, the data_type field MUST be
655+ // UINT32 or UINT64
656+ repeated uint64 uint64_data = 11 [packed = true];
657+
658+ // Named metadata values; keys should be distinct.
659+ repeated StringStringEntryProto metadata_props = 16;
660+}
661+
662+// A serialized sparse-tensor value
663+message SparseTensorProto {
664+ // The sequence of non-default values are encoded as a tensor of shape [NNZ].
665+ // The default-value is zero for numeric tensors, and empty-string for string tensors.
666+ // values must have a non-empty name present which serves as a name for SparseTensorProto
667+ // when used in sparse_initializer list.
668+ optional TensorProto values = 1;
669+
670+ // The indices of the non-default values, which may be stored in one of two formats.
671+ // (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
672+ // corresponding to the j-th index of the i-th value (in the values tensor).
673+ // (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
674+ // must be the linearized-index of the i-th value (in the values tensor).
675+ // The linearized-index can be converted into an index tuple (k_1,...,k_rank)
676+ // using the shape provided below.
677+ // The indices must appear in ascending order without duplication.
678+ // In the first format, the ordering is lexicographic-ordering:
679+ // e.g., index-value [1,4] must appear before [2,1]
680+ optional TensorProto indices = 2;
681+
682+ // The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
683+ repeated int64 dims = 3;
684+}
685+
686+// Defines a tensor shape. A dimension can be either an integer value
687+// or a symbolic variable. A symbolic variable represents an unknown
688+// dimension.
689+message TensorShapeProto {
690+ message Dimension {
691+ oneof value {
692+ int64 dim_value = 1;
693+ string dim_param = 2; // namespace Shape
694+ };
695+ // Standard denotation can optionally be used to denote tensor
696+ // dimensions with standard semantic descriptions to ensure
697+ // that operations are applied to the correct axis of a tensor.
698+ // Refer to https://github.com/onnx/onnx/blob/main/docs/DimensionDenotation.md#denotation-definition
699+ // for pre-defined dimension denotations.
700+ optional string denotation = 3;
701+ };
702+ repeated Dimension dim = 1;
703+}
704+
705+// Types
706+//
707+// The standard ONNX data types.
708+message TypeProto {
709+
710+ message Tensor {
711+ // This field MUST NOT have the value of UNDEFINED
712+ // This field MUST have a valid TensorProto.DataType value
713+ // This field MUST be present for this version of the IR.
714+ optional int32 elem_type = 1;
715+ optional TensorShapeProto shape = 2;
716+ }
717+
718+ // repeated T
719+ message Sequence {
720+ // The type and optional shape of each element of the sequence.
721+ // This field MUST be present for this version of the IR.
722+ optional TypeProto elem_type = 1;
723+ };
724+
725+ // map<K,V>
726+ message Map {
727+ // This field MUST have a valid TensorProto.DataType value
728+ // This field MUST be present for this version of the IR.
729+ // This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
730+ optional int32 key_type = 1;
731+ // This field MUST be present for this version of the IR.
732+ optional TypeProto value_type = 2;
733+ };
734+
735+ // wrapper for Tensor, Sequence, or Map
736+ message Optional {
737+ // The type and optional shape of the element wrapped.
738+ // This field MUST be present for this version of the IR.
739+ // Possible values correspond to OptionalProto.DataType enum
740+ optional TypeProto elem_type = 1;
741+ };
742+
743+
744+ message SparseTensor {
745+ // This field MUST NOT have the value of UNDEFINED
746+ // This field MUST have a valid TensorProto.DataType value
747+ // This field MUST be present for this version of the IR.
748+ optional int32 elem_type = 1;
749+ optional TensorShapeProto shape = 2;
750+ }
751+
752+
753+ message Opaque {
754+ // When missing, the domain is the same as the model's.
755+ optional string domain = 1;
756+ // The name is optional but significant when provided.
757+ optional string name = 2;
758+ // parameters that help defining the type
759+ // DEPRECATED do not use.
760+ // repeated TypeProto parameters = 3;
761+ }
762+
763+
764+ oneof value {
765+ // The type of a tensor.
766+ Tensor tensor_type = 1;
767+
768+ // NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
769+ // as input and output to graphs and nodes. These types are needed to naturally
770+ // support classical ML operators. DNN operators SHOULD restrict their input
771+ // and output types to tensors.
772+
773+ // The type of a sequence.
774+ Sequence sequence_type = 4;
775+
776+ // The type of a map.
777+ Map map_type = 5;
778+
779+ // The type of an optional.
780+ Optional optional_type = 9;
781+
782+
783+ // Type of the sparse tensor
784+ SparseTensor sparse_tensor_type = 8;
785+
786+
787+ Opaque opaque_type = 7;
788+
789+ }
790+
791+ // An optional denotation can be used to denote the whole
792+ // type with a standard semantic description as to what is
793+ // stored inside. Refer to https://github.com/onnx/onnx/blob/main/docs/TypeDenotation.md#type-denotation-definition
794+ // for pre-defined type denotations.
795+ optional string denotation = 6;
796+}
797+
798+// Operator Sets
799+//
800+// OperatorSets are uniquely identified by a (domain, opset_version) pair.
801+message OperatorSetIdProto {
802+ // The domain of the operator set being identified.
803+ // The empty string ("") or absence of this field implies the operator
804+ // set that is defined as part of the ONNX specification.
805+ // This field MUST be present in this version of the IR when referring to any other operator set.
806+ optional string domain = 1;
807+
808+ // The version of the operator set being identified.
809+ // This field MUST be present in this version of the IR.
810+ optional int64 version = 2;
811+}
812+
813+// Operator/function status.
814+enum OperatorStatus {
815+ EXPERIMENTAL = 0;
816+ STABLE = 1;
817+}
818+
819+message FunctionProto {
820+ // The name of the function, similar to op_type in NodeProto.
821+ // This is part of the unique-id (domain, name, overload) of FunctionProtos in a model.
822+ optional string name = 1;
823+
824+ // Deprecated since IR Version 8
825+ // optional int64 since_version = 2;
826+ reserved 2;
827+ reserved "since_version";
828+
829+ // Deprecated since IR Version 8
830+ // optional OperatorStatus status = 3;
831+ reserved 3;
832+ reserved "status";
833+
834+ // The inputs and outputs of the function.
835+ repeated string input = 4;
836+ repeated string output = 5;
837+
838+ // The attribute parameters of the function.
839+ // It is for function parameters without default values.
840+ repeated string attribute = 6;
841+
842+ // The attribute protos of the function.
843+ // It is for function attributes with default values.
844+ // A function attribute shall be represented either as
845+ // a string attribute or an AttributeProto, not both.
846+ repeated AttributeProto attribute_proto = 11;
847+
848+ // The nodes in the function.
849+ repeated NodeProto node = 7;
850+ // A human-readable documentation for this function. Markdown is allowed.
851+ optional string doc_string = 8;
852+
853+ // The OperatorSets this function body (graph) relies on.
854+ //
855+ // All nodes in the function body (graph) will bind against the operator
856+ // with the same-domain/same-op_type operator with the HIGHEST version
857+ // in the referenced operator sets. This means at most one version can be relied
858+ // for one domain.
859+ //
860+ // The operator sets imported by FunctionProto should be compatible with the ones
861+ // imported by ModelProto. Example, if same operator set say 'A' is imported by FunctionProto
862+ // and ModelProto then versions for the operator set may be different but,
863+ // the operator schema returned for op_type, domain, version combination
864+ // for both the versions should be same.
865+
866+ repeated OperatorSetIdProto opset_import = 9;
867+
868+ // The domain which this function belongs to.
869+ // This is part of the unique-id (domain, name, overload) of FunctionProtos in a model.
870+ optional string domain = 10;
871+
872+ // The overload identifier of the function.
873+ // This is part of the unique-id (domain, name, overload) of FunctionProtos in a model.
874+ optional string overload = 13;
875+
876+ // Information for the values in the function. The ValueInfoProto.name's
877+ // must be distinct and refer to names in the function (including inputs,
878+ // outputs, and intermediate values). It is optional for a value to appear
879+ // in value_info list.
880+ repeated ValueInfoProto value_info = 12;
881+
882+ // Named metadata values; keys should be distinct.
883+ repeated StringStringEntryProto metadata_props = 14;
884+}
885+
886+// For using protobuf-lite
887+option optimize_for = LITE_RUNTIME;
888+
added tools/pnnx/src/onnx-operators-ml.proto +136 −0
@@ -0,0 +1,136 @@
1+//
2+// WARNING: This file is automatically generated! Please edit onnx.in.proto.
3+//
4+
5+
6+// Copyright (c) ONNX Project Contributors.
7+// Licensed under the Apache-2.0 license.
8+
9+syntax = "proto2";
10+
11+package onnx;
12+import "onnx-ml.proto";
13+
14+//
15+// This file contains the proto definitions for OperatorSetProto and
16+// OperatorProto. OperatorSetProtos are used to describe a versioned
17+// set of operators that can be used by a ModelProto.
18+//
19+// Like ModelProto, OperatorSetProto is defined as a top-level file/wire
20+// format, however their usage is different.
21+//
22+// ModelProto files are used to describe executable graphs that can be
23+// executed directly by a framework, runtime, or engine.
24+//
25+// OperatorSetProto files are used to describe a set of operators that are
26+// available in a given environment. The file TBD.TBD is the OperatorSetProto
27+// that describes the ONNX standard operators.
28+//
29+
30+// An OperatorProto represents the immutable specification of the signature
31+// and semantics of an operator.
32+//
33+// Operators are declared as part of an OperatorSet, which also defines the
34+// domain name for the set.
35+//
36+// Operators are uniquely identified by a three part identifier
37+// (domain, op_type, since_version)
38+// where
39+// *domain* is the domain of an operator set that
40+// contains this operator specification.
41+//
42+// *op_type* is the name of the operator as referenced by a
43+// NodeProto.op_type
44+//
45+// *since_version* is the version of the operator set that
46+// this operator was initially declared in.
47+//
48+message OperatorProto {
49+ // The name of the operator within a domain.
50+ // This field MUST be present in this version of the IR.
51+ optional string op_type = 1;
52+
53+ // The version of the operator set that first introduced this
54+ // operator. This value MUST be the same value as the
55+ // opset_version of the operator set that first published this operator.
56+ // Subsequent versions of the operator set MUST NOT alter the signature
57+ // or semantics of the operator once published as STABLE.
58+ // This field MUST be present in this version of the IR.
59+ optional int64 since_version = 2;
60+
61+ // This field indicates whether the syntax, semantics, or presence
62+ // of this operator is in an experimental or stable stage. Once an
63+ // operator is published as STABLE, it's syntax and semantics MUST NOT
64+ // change in subsequent versions of the operator set.
65+ // When an operator is published as EXPERIMENTAL, the syntax and semantics
66+ // of the operator MAY change across operator set versions.
67+ // Operators "become" stable by deprecating the experimental version and
68+ // introducing a new stable operator with the same op_type.
69+ optional OperatorStatus status = 3;
70+
71+ // Eventually we will declare the signature of the operator here
72+
73+ // A human-readable documentation for this operator. Markdown is allowed.
74+ optional string doc_string = 10;
75+}
76+
77+// An OperatorSetProto represents an immutable set of immutable operator
78+// specifications.
79+//
80+// The domain of the set (OperatorSetProto.domain) is a reverse-DNS name
81+// that disambiguates operator sets defined by independent entities.
82+//
83+// The version of the set (opset_version) is a monotonically increasing
84+// integer that indicates changes to the membership of the operator set.
85+//
86+//
87+// Operator sets are uniquely identified by a two part identifier (domain, opset_version)
88+//
89+// Like ModelProto, OperatorSetProto is intended as a top-level file/wire format,
90+// and thus has the standard format headers in addition to the operator set information.
91+//
92+message OperatorSetProto {
93+ // All OperatorSetProtos start with a distingushed byte sequence to disambiguate
94+ // protobuf files containing OperatorSets from other content.
95+ // This field MUST be "ONNXOPSET"
96+ // This field MUST be present in this version of the IR
97+ optional string magic = 1;
98+
99+ // All OperatorSetProtos indicate the version of the IR syntax and semantics
100+ // they adhere to. It is always IR_VERSION.
101+ // This field MUST be present in this version of the IR
102+ optional int64 ir_version = 2;
103+
104+ // The prerelease component of the SemVer of the IR.
105+ // This field MAY be absent in this version of the IR
106+ optional string ir_version_prerelease = 3;
107+
108+ // The build metadata component of the SemVer of the IR.
109+ // This field MAY be absent in this version of the IR
110+ optional string ir_build_metadata = 7;
111+
112+ // Domain name of the operator set, in reverse DNS form (e.g., com.acme.dnnops).
113+ optional string domain = 4;
114+
115+ // The version of the set of operators. This is a simple int value
116+ // that is monotonically increasing as new versions of the operator set
117+ // are published. All operators in this set MUST have since_version
118+ // <= opset_version.
119+ optional int64 opset_version = 5;
120+
121+ // A human-readable documentation for this set of operators. Markdown is allowed.
122+ optional string doc_string = 6;
123+
124+ // The operators specified by this operator set.
125+ // The (name, version) MUST be unique across all OperatorProtos in operator
126+ repeated OperatorProto operator = 8;
127+
128+ // The functions specified by this operator set.
129+ // The (name, version) MUST be unique across all OperatorProtos/FunctionProtos in operator/functions
130+ repeated FunctionProto functions = 9;
131+}
132+
133+
134+// For using protobuf-lite
135+option optimize_for = LITE_RUNTIME;
136+
deleted tools/pnnx/src/onnx.proto +0 −836
@@ -1,836 +0,0 @@
1-//
2-// WARNING: This file is automatically generated! Please edit onnx.in.proto.
3-//
4-
5-
6-// SPDX-License-Identifier: Apache-2.0
7-
8-
9-syntax = "proto2";
10-
11-package onnx;
12-
13-// Overview
14-//
15-// ONNX is an open specification that is comprised of the following components:
16-//
17-// 1) A definition of an extensible computation graph model.
18-// 2) Definitions of standard data types.
19-// 3) Definitions of built-in operators.
20-//
21-// This document describes the syntax of models and their computation graphs,
22-// as well as the standard data types. Together, they are referred to as the ONNX
23-// Intermediate Representation, or 'IR' for short.
24-//
25-// The normative semantic specification of the ONNX IR is found in docs/IR.md.
26-// Definitions of the built-in neural network operators may be found in docs/Operators.md.
27-
28-// Notes
29-//
30-// Protobuf compatibility
31-//
32-// To simplify framework compatibility, ONNX is defined using the subset of protobuf
33-// that is compatible with both protobuf v2 and v3. This means that we do not use any
34-// protobuf features that are only available in one of the two versions.
35-//
36-// Here are the most notable contortions we have to carry out to work around
37-// these limitations:
38-//
39-// - No 'map' (added protobuf 3.0). We instead represent mappings as lists
40-// of key-value pairs, where order does not matter and duplicates
41-// are not allowed.
42-
43-
44-// Versioning
45-//
46-// ONNX versioning is specified in docs/IR.md and elaborated on in docs/Versioning.md
47-//
48-// To be compatible with both proto2 and proto3, we will use a version number
49-// that is not defined by the default value but an explicit enum number.
50-enum Version {
51- // proto3 requires the first enum value to be zero.
52- // We add this just to appease the compiler.
53- _START_VERSION = 0;
54- // The version field is always serialized and we will use it to store the
55- // version that the graph is generated from. This helps us set up version
56- // control.
57- // For the IR, we are using simple numbers starting with 0x00000001,
58- // which was the version we published on Oct 10, 2017.
59- IR_VERSION_2017_10_10 = 0x0000000000000001;
60-
61- // IR_VERSION 2 published on Oct 30, 2017
62- // - Added type discriminator to AttributeProto to support proto3 users
63- IR_VERSION_2017_10_30 = 0x0000000000000002;
64-
65- // IR VERSION 3 published on Nov 3, 2017
66- // - For operator versioning:
67- // - Added new message OperatorSetIdProto
68- // - Added opset_import in ModelProto
69- // - For vendor extensions, added domain in NodeProto
70- IR_VERSION_2017_11_3 = 0x0000000000000003;
71-
72- // IR VERSION 4 published on Jan 22, 2019
73- // - Relax constraint that initializers should be a subset of graph inputs
74- // - Add type BFLOAT16
75- IR_VERSION_2019_1_22 = 0x0000000000000004;
76-
77- // IR VERSION 5 published on March 18, 2019
78- // - Add message TensorAnnotation.
79- // - Add quantization annotation in GraphProto to map tensor with its scale and zero point quantization parameters.
80- IR_VERSION_2019_3_18 = 0x0000000000000005;
81-
82- // IR VERSION 6 published on Sep 19, 2019
83- // - Add support for sparse tensor constants stored in model.
84- // - Add message SparseTensorProto
85- // - Add sparse initializers
86- IR_VERSION_2019_9_19 = 0x0000000000000006;
87-
88- // IR VERSION 7 published on May 8, 2020
89- // - Add support to allow function body graph to rely on multiple external opreator sets.
90- // - Add a list to promote inference graph's initializers to global and
91- // mutable variables. Global variables are visible in all graphs of the
92- // stored models.
93- // - Add message TrainingInfoProto to store initialization
94- // method and training algorithm. The execution of TrainingInfoProto
95- // can modify the values of mutable variables.
96- // - Implicitly add inference graph into each TrainingInfoProto's algorithm.
97- IR_VERSION_2020_5_8 = 0x0000000000000007;
98-
99- // IR VERSION 8 published on July 30, 2021
100- // Introduce TypeProto.SparseTensor
101- // Introduce TypeProto.Optional
102- // Added a list of FunctionProtos local to the model
103- // Deprecated since_version and operator status from FunctionProto
104- IR_VERSION_2021_7_30 = 0x0000000000000008;
105-
106- // IR VERSION 9 published on May 5, 2023
107- // Added AttributeProto to FunctionProto so that default attribute values can be set.
108- // Added FLOAT8E4M3FN, FLOAT8E4M3FNUZ, FLOAT8E5M2, FLOAT8E5M2FNUZ.
109- IR_VERSION = 0x0000000000000009;
110-}
111-
112-// Attributes
113-//
114-// A named attribute containing either singular float, integer, string, graph,
115-// and tensor values, or repeated float, integer, string, graph, and tensor values.
116-// An AttributeProto MUST contain the name field, and *only one* of the
117-// following content fields, effectively enforcing a C/C++ union equivalent.
118-message AttributeProto {
119- reserved 12, 16 to 19;
120- reserved "v";
121-
122- // Note: this enum is structurally identical to the OpSchema::AttrType
123- // enum defined in schema.h. If you rev one, you likely need to rev the other.
124- enum AttributeType {
125- UNDEFINED = 0;
126- FLOAT = 1;
127- INT = 2;
128- STRING = 3;
129- TENSOR = 4;
130- GRAPH = 5;
131- SPARSE_TENSOR = 11;
132- TYPE_PROTO = 13;
133-
134- FLOATS = 6;
135- INTS = 7;
136- STRINGS = 8;
137- TENSORS = 9;
138- GRAPHS = 10;
139- SPARSE_TENSORS = 12;
140- TYPE_PROTOS = 14;
141- }
142-
143- // The name field MUST be present for this version of the IR.
144- optional string name = 1; // namespace Attribute
145-
146- // if ref_attr_name is not empty, ref_attr_name is the attribute name in parent function.
147- // In this case, this AttributeProto does not contain data, and it's a reference of attribute
148- // in parent scope.
149- // NOTE: This should ONLY be used in function (sub-graph). It's invalid to be used in main graph.
150- optional string ref_attr_name = 21;
151-
152- // A human-readable documentation for this attribute. Markdown is allowed.
153- optional string doc_string = 13;
154-
155- // The type field MUST be present for this version of the IR.
156- // For 0.0.1 versions of the IR, this field was not defined, and
157- // implementations needed to use has_field heuristics to determine
158- // which value field was in use. For IR_VERSION 0.0.2 or later, this
159- // field MUST be set and match the f|i|s|t|... field in use. This
160- // change was made to accommodate proto3 implementations.
161- optional AttributeType type = 20; // discriminator that indicates which field below is in use
162-
163- // Exactly ONE of the following fields must be present for this version of the IR
164- optional float f = 2; // float
165- optional int64 i = 3; // int
166- optional bytes s = 4; // UTF-8 string
167- optional TensorProto t = 5; // tensor value
168- optional GraphProto g = 6; // graph
169- optional SparseTensorProto sparse_tensor = 22; // sparse tensor value
170- // Do not use field below, it's deprecated.
171- // optional ValueProto v = 12; // value - subsumes everything but graph
172- optional TypeProto tp = 14; // type proto
173-
174- repeated float floats = 7; // list of floats
175- repeated int64 ints = 8; // list of ints
176- repeated bytes strings = 9; // list of UTF-8 strings
177- repeated TensorProto tensors = 10; // list of tensors
178- repeated GraphProto graphs = 11; // list of graph
179- repeated SparseTensorProto sparse_tensors = 23; // list of sparse tensors
180- repeated TypeProto type_protos = 15;// list of type protos
181-}
182-
183-// Defines information on value, including the name, the type, and
184-// the shape of the value.
185-message ValueInfoProto {
186- // This field MUST be present in this version of the IR.
187- optional string name = 1; // namespace Value
188- // This field MUST be present in this version of the IR for
189- // inputs and outputs of the top-level graph.
190- optional TypeProto type = 2;
191- // A human-readable documentation for this value. Markdown is allowed.
192- optional string doc_string = 3;
193-}
194-
195-// Nodes
196-//
197-// Computation graphs are made up of a DAG of nodes, which represent what is
198-// commonly called a "layer" or "pipeline stage" in machine learning frameworks.
199-//
200-// For example, it can be a node of type "Conv" that takes in an image, a filter
201-// tensor and a bias tensor, and produces the convolved output.
202-message NodeProto {
203- repeated string input = 1; // namespace Value
204- repeated string output = 2; // namespace Value
205-
206- // An optional identifier for this node in a graph.
207- // This field MAY be absent in ths version of the IR.
208- optional string name = 3; // namespace Node
209-
210- // The symbolic identifier of the Operator to execute.
211- optional string op_type = 4; // namespace Operator
212- // The domain of the OperatorSet that specifies the operator named by op_type.
213- optional string domain = 7; // namespace Domain
214-
215- // Additional named attributes.
216- repeated AttributeProto attribute = 5;
217-
218- // A human-readable documentation for this node. Markdown is allowed.
219- optional string doc_string = 6;
220-}
221-
222-// Training information
223-// TrainingInfoProto stores information for training a model.
224-// In particular, this defines two functionalities: an initialization-step
225-// and a training-algorithm-step. Initialization resets the model
226-// back to its original state as if no training has been performed.
227-// Training algorithm improves the model based on input data.
228-//
229-// The semantics of the initialization-step is that the initializers
230-// in ModelProto.graph and in TrainingInfoProto.algorithm are first
231-// initialized as specified by the initializers in the graph, and then
232-// updated by the "initialization_binding" in every instance in
233-// ModelProto.training_info.
234-//
235-// The field "algorithm" defines a computation graph which represents a
236-// training algorithm's step. After the execution of a
237-// TrainingInfoProto.algorithm, the initializers specified by "update_binding"
238-// may be immediately updated. If the targeted training algorithm contains
239-// consecutive update steps (such as block coordinate descent methods),
240-// the user needs to create a TrainingInfoProto for each step.
241-message TrainingInfoProto {
242- // This field describes a graph to compute the initial tensors
243- // upon starting the training process. Initialization graph has no input
244- // and can have multiple outputs. Usually, trainable tensors in neural
245- // networks are randomly initialized. To achieve that, for each tensor,
246- // the user can put a random number operator such as RandomNormal or
247- // RandomUniform in TrainingInfoProto.initialization.node and assign its
248- // random output to the specific tensor using "initialization_binding".
249- // This graph can also set the initializers in "algorithm" in the same
250- // TrainingInfoProto; a use case is resetting the number of training
251- // iteration to zero.
252- //
253- // By default, this field is an empty graph and its evaluation does not
254- // produce any output. Thus, no initializer would be changed by default.
255- optional GraphProto initialization = 1;
256-
257- // This field represents a training algorithm step. Given required inputs,
258- // it computes outputs to update initializers in its own or inference graph's
259- // initializer lists. In general, this field contains loss node, gradient node,
260- // optimizer node, increment of iteration count.
261- //
262- // An execution of the training algorithm step is performed by executing the
263- // graph obtained by combining the inference graph (namely "ModelProto.graph")
264- // and the "algorithm" graph. That is, the actual
265- // input/initializer/output/node/value_info/sparse_initializer list of
266- // the training graph is the concatenation of
267- // "ModelProto.graph.input/initializer/output/node/value_info/sparse_initializer"
268- // and "algorithm.input/initializer/output/node/value_info/sparse_initializer"
269- // in that order. This combined graph must satisfy the normal ONNX conditions.
270- // Now, let's provide a visualization of graph combination for clarity.
271- // Let the inference graph (i.e., "ModelProto.graph") be
272- // tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d
273- // and the "algorithm" graph be
274- // tensor_d -> Add -> tensor_e
275- // The combination process results
276- // tensor_a, tensor_b -> MatMul -> tensor_c -> Sigmoid -> tensor_d -> Add -> tensor_e
277- //
278- // Notice that an input of a node in the "algorithm" graph may reference the
279- // output of a node in the inference graph (but not the other way round). Also, inference
280- // node cannot reference inputs of "algorithm". With these restrictions, inference graph
281- // can always be run independently without training information.
282- //
283- // By default, this field is an empty graph and its evaluation does not
284- // produce any output. Evaluating the default training step never
285- // update any initializers.
286- optional GraphProto algorithm = 2;
287-
288- // This field specifies the bindings from the outputs of "initialization" to
289- // some initializers in "ModelProto.graph.initializer" and
290- // the "algorithm.initializer" in the same TrainingInfoProto.
291- // See "update_binding" below for details.
292- //
293- // By default, this field is empty and no initializer would be changed
294- // by the execution of "initialization".
295- repeated StringStringEntryProto initialization_binding = 3;
296-
297- // Gradient-based training is usually an iterative procedure. In one gradient
298- // descent iteration, we apply
299- //
300- // x = x - r * g
301- //
302- // where "x" is the optimized tensor, "r" stands for learning rate, and "g" is
303- // gradient of "x" with respect to a chosen loss. To avoid adding assignments
304- // into the training graph, we split the update equation into
305- //
306- // y = x - r * g
307- // x = y
308- //
309- // The user needs to save "y = x - r * g" into TrainingInfoProto.algorithm. To
310- // tell that "y" should be assigned to "x", the field "update_binding" may
311- // contain a key-value pair of strings, "x" (key of StringStringEntryProto)
312- // and "y" (value of StringStringEntryProto).
313- // For a neural network with multiple trainable (mutable) tensors, there can
314- // be multiple key-value pairs in "update_binding".
315- //
316- // The initializers appears as keys in "update_binding" are considered
317- // mutable variables. This implies some behaviors
318- // as described below.
319- //
320- // 1. We have only unique keys in all "update_binding"s so that two
321- // variables may not have the same name. This ensures that one
322- // variable is assigned up to once.
323- // 2. The keys must appear in names of "ModelProto.graph.initializer" or
324- // "TrainingInfoProto.algorithm.initializer".
325- // 3. The values must be output names of "algorithm" or "ModelProto.graph.output".
326- // 4. Mutable variables are initialized to the value specified by the
327- // corresponding initializer, and then potentially updated by
328- // "initializer_binding"s and "update_binding"s in "TrainingInfoProto"s.
329- //
330- // This field usually contains names of trainable tensors
331- // (in ModelProto.graph), optimizer states such as momentums in advanced
332- // stochastic gradient methods (in TrainingInfoProto.graph),
333- // and number of training iterations (in TrainingInfoProto.graph).
334- //
335- // By default, this field is empty and no initializer would be changed
336- // by the execution of "algorithm".
337- repeated StringStringEntryProto update_binding = 4;
338-}
339-
340-// Models
341-//
342-// ModelProto is a top-level file/container format for bundling a ML model and
343-// associating its computation graph with metadata.
344-//
345-// The semantics of the model are described by the associated GraphProto's.
346-message ModelProto {
347- // The version of the IR this model targets. See Version enum above.
348- // This field MUST be present.
349- optional int64 ir_version = 1;
350-
351- // The OperatorSets this model relies on.
352- // All ModelProtos MUST have at least one entry that
353- // specifies which version of the ONNX OperatorSet is
354- // being imported.
355- //
356- // All nodes in the ModelProto's graph will bind against the operator
357- // with the same-domain/same-op_type operator with the HIGHEST version
358- // in the referenced operator sets.
359- repeated OperatorSetIdProto opset_import = 8;
360-
361- // The name of the framework or tool used to generate this model.
362- // This field SHOULD be present to indicate which implementation/tool/framework
363- // emitted the model.
364- optional string producer_name = 2;
365-
366- // The version of the framework or tool used to generate this model.
367- // This field SHOULD be present to indicate which implementation/tool/framework
368- // emitted the model.
369- optional string producer_version = 3;
370-
371- // Domain name of the model.
372- // We use reverse domain names as name space indicators. For example:
373- // `com.facebook.fair` or `com.microsoft.cognitiveservices`
374- //
375- // Together with `model_version` and GraphProto.name, this forms the unique identity of
376- // the graph.
377- optional string domain = 4;
378-
379- // The version of the graph encoded. See Version enum below.
380- optional int64 model_version = 5;
381-
382- // A human-readable documentation for this model. Markdown is allowed.
383- optional string doc_string = 6;
384-
385- // The parameterized graph that is evaluated to execute the model.
386- optional GraphProto graph = 7;
387-
388- // Named metadata values; keys should be distinct.
389- repeated StringStringEntryProto metadata_props = 14;
390-
391- // Training-specific information. Sequentially executing all stored
392- // `TrainingInfoProto.algorithm`s and assigning their outputs following
393- // the corresponding `TrainingInfoProto.update_binding`s is one training
394- // iteration. Similarly, to initialize the model
395- // (as if training hasn't happened), the user should sequentially execute
396- // all stored `TrainingInfoProto.initialization`s and assigns their outputs
397- // using `TrainingInfoProto.initialization_binding`s.
398- //
399- // If this field is empty, the training behavior of the model is undefined.
400- repeated TrainingInfoProto training_info = 20;
401-
402- // A list of function protos local to the model.
403- //
404- // Name of the function "FunctionProto.name" should be unique within the domain "FunctionProto.domain".
405- // In case of any conflicts the behavior (whether the model local functions are given higher priority,
406- // or standard operator sets are given higher priotity or this is treated as error) is defined by
407- // the runtimes.
408- //
409- // The operator sets imported by FunctionProto should be compatible with the ones
410- // imported by ModelProto and other model local FunctionProtos.
411- // Example, if same operator set say 'A' is imported by a FunctionProto and ModelProto
412- // or by 2 FunctionProtos then versions for the operator set may be different but,
413- // the operator schema returned for op_type, domain, version combination
414- // for both the versions should be same for every node in the function body.
415- //
416- // One FunctionProto can reference other FunctionProto in the model, however, recursive reference
417- // is not allowed.
418- repeated FunctionProto functions = 25;
419-};
420-
421-// StringStringEntryProto follows the pattern for cross-proto-version maps.
422-// See https://developers.google.com/protocol-buffers/docs/proto3#maps
423-message StringStringEntryProto {
424- optional string key = 1;
425- optional string value = 2;
426-};
427-
428-message TensorAnnotation {
429- optional string tensor_name = 1;
430- // <key, value> pairs to annotate tensor specified by <tensor_name> above.
431- // The keys used in the mapping below must be pre-defined in ONNX spec.
432- // For example, for 8-bit linear quantization case, 'SCALE_TENSOR', 'ZERO_POINT_TENSOR' will be pre-defined as
433- // quantization parameter keys.
434- repeated StringStringEntryProto quant_parameter_tensor_names = 2;
435-}
436-
437-
438-
439-// Graphs
440-//
441-// A graph defines the computational logic of a model and is comprised of a parameterized
442-// list of nodes that form a directed acyclic graph based on their inputs and outputs.
443-// This is the equivalent of the "network" or "graph" in many deep learning
444-// frameworks.
445-message GraphProto {
446- // The nodes in the graph, sorted topologically.
447- repeated NodeProto node = 1;
448-
449- // The name of the graph.
450- optional string name = 2; // namespace Graph
451-
452- // A list of named tensor values, used to specify constant inputs of the graph.
453- // Each initializer (both TensorProto as well SparseTensorProto) MUST have a name.
454- // The name MUST be unique across both initializer and sparse_initializer,
455- // but the name MAY also appear in the input list.
456- repeated TensorProto initializer = 5;
457-
458- // Initializers (see above) stored in sparse format.
459- repeated SparseTensorProto sparse_initializer = 15;
460-
461- // A human-readable documentation for this graph. Markdown is allowed.
462- optional string doc_string = 10;
463-
464- // The inputs and outputs of the graph.
465- repeated ValueInfoProto input = 11;
466- repeated ValueInfoProto output = 12;
467-
468- // Information for the values in the graph. The ValueInfoProto.name's
469- // must be distinct. It is optional for a value to appear in value_info list.
470- repeated ValueInfoProto value_info = 13;
471-
472- // This field carries information to indicate the mapping among a tensor and its
473- // quantization parameter tensors. For example:
474- // For tensor 'a', it may have {'SCALE_TENSOR', 'a_scale'} and {'ZERO_POINT_TENSOR', 'a_zero_point'} annotated,
475- // which means, tensor 'a_scale' and tensor 'a_zero_point' are scale and zero point of tensor 'a' in the model.
476- repeated TensorAnnotation quantization_annotation = 14;
477-
478- reserved 3, 4, 6 to 9;
479- reserved "ir_version", "producer_version", "producer_tag", "domain";
480-}
481-
482-// Tensors
483-//
484-// A serialized tensor value.
485-message TensorProto {
486- enum DataType {
487- UNDEFINED = 0;
488- // Basic types.
489- FLOAT = 1; // float
490- UINT8 = 2; // uint8_t
491- INT8 = 3; // int8_t
492- UINT16 = 4; // uint16_t
493- INT16 = 5; // int16_t
494- INT32 = 6; // int32_t
495- INT64 = 7; // int64_t
496- STRING = 8; // string
497- BOOL = 9; // bool
498-
499- // IEEE754 half-precision floating-point format (16 bits wide).
500- // This format has 1 sign bit, 5 exponent bits, and 10 mantissa bits.
501- FLOAT16 = 10;
502-
503- DOUBLE = 11;
504- UINT32 = 12;
505- UINT64 = 13;
506- COMPLEX64 = 14; // complex with float32 real and imaginary components
507- COMPLEX128 = 15; // complex with float64 real and imaginary components
508-
509- // Non-IEEE floating-point format based on IEEE754 single-precision
510- // floating-point number truncated to 16 bits.
511- // This format has 1 sign bit, 8 exponent bits, and 7 mantissa bits.
512- BFLOAT16 = 16;
513-
514- // Non-IEEE floating-point format based on papers
515- // FP8 Formats for Deep Learning, https://arxiv.org/abs/2209.05433,
516- // 8-bit Numerical Formats For Deep Neural Networks, https://arxiv.org/pdf/2206.02915.pdf.
517- // Operators supported FP8 are Cast, CastLike, QuantizeLinear, DequantizeLinear.
518- // The computation usually happens inside a block quantize / dequantize
519- // fused by the runtime.
520- FLOAT8E4M3FN = 17; // float 8, mostly used for coefficients, supports nan, not inf
521- FLOAT8E4M3FNUZ = 18; // float 8, mostly used for coefficients, supports nan, not inf, no negative zero
522- FLOAT8E5M2 = 19; // follows IEEE 754, supports nan, inf, mostly used for gradients
523- FLOAT8E5M2FNUZ = 20; // follows IEEE 754, supports nan, inf, mostly used for gradients, no negative zero
524-
525- // Future extensions go here.
526- }
527-
528- // The shape of the tensor.
529- repeated int64 dims = 1;
530-
531- // The data type of the tensor.
532- // This field MUST have a valid TensorProto.DataType value
533- optional int32 data_type = 2;
534-
535- // For very large tensors, we may want to store them in chunks, in which
536- // case the following fields will specify the segment that is stored in
537- // the current TensorProto.
538- message Segment {
539- optional int64 begin = 1;
540- optional int64 end = 2;
541- }
542- optional Segment segment = 3;
543-
544- // Tensor content must be organized in row-major order.
545- //
546- // Depending on the data_type field, exactly one of the fields below with
547- // name ending in _data is used to store the elements of the tensor.
548-
549- // For float and complex64 values
550- // Complex64 tensors are encoded as a single array of floats,
551- // with the real components appearing in odd numbered positions,
552- // and the corresponding imaginary component appearing in the
553- // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
554- // is encoded as [1.0, 2.0 ,3.0 ,4.0]
555- // When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
556- repeated float float_data = 4 [packed = true];
557-
558- // For int32, uint8, int8, uint16, int16, bool, float8, and float16 values
559- // float16 and float8 values must be bit-wise converted to an uint16_t prior
560- // to writing to the buffer.
561- // When this field is present, the data_type field MUST be
562- // INT32, INT16, INT8, UINT16, UINT8, BOOL, FLOAT16, BFLOAT16, FLOAT8E4M3FN, FLOAT8E4M3FNUZ, FLOAT8E5M2, FLOAT8E5M2FNUZ
563- repeated int32 int32_data = 5 [packed = true];
564-
565- // For strings.
566- // Each element of string_data is a UTF-8 encoded Unicode
567- // string. No trailing null, no leading BOM. The protobuf "string"
568- // scalar type is not used to match ML community conventions.
569- // When this field is present, the data_type field MUST be STRING
570- repeated bytes string_data = 6;
571-
572- // For int64.
573- // When this field is present, the data_type field MUST be INT64
574- repeated int64 int64_data = 7 [packed = true];
575-
576- // Optionally, a name for the tensor.
577- optional string name = 8; // namespace Value
578-
579- // A human-readable documentation for this tensor. Markdown is allowed.
580- optional string doc_string = 12;
581-
582- // Serializations can either use one of the fields above, or use this
583- // raw bytes field. The only exception is the string case, where one is
584- // required to store the content in the repeated bytes string_data field.
585- //
586- // When this raw_data field is used to store tensor value, elements MUST
587- // be stored in as fixed-width, little-endian order.
588- // Floating-point data types MUST be stored in IEEE 754 format.
589- // Complex64 elements must be written as two consecutive FLOAT values, real component first.
590- // Complex128 elements must be written as two consecutive DOUBLE values, real component first.
591- // Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
592- //
593- // Note: the advantage of specific field rather than the raw_data field is
594- // that in some cases (e.g. int data), protobuf does a better packing via
595- // variable length storage, and may lead to smaller binary footprint.
596- // When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
597- optional bytes raw_data = 9;
598-
599- // Data can be stored inside the protobuf file using type-specific fields or raw_data.
600- // Alternatively, raw bytes data can be stored in an external file, using the external_data field.
601- // external_data stores key-value pairs describing data location. Recognized keys are:
602- // - "location" (required) - POSIX filesystem path relative to the directory where the ONNX
603- // protobuf model was stored
604- // - "offset" (optional) - position of byte at which stored data begins. Integer stored as string.
605- // Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
606- // - "length" (optional) - number of bytes containing data. Integer stored as string.
607- // - "checksum" (optional) - SHA1 digest of file specified in under 'location' key.
608- repeated StringStringEntryProto external_data = 13;
609-
610- // Location of the data for this tensor. MUST be one of:
611- // - DEFAULT - data stored inside the protobuf message. Data is stored in raw_data (if set) otherwise in type-specified field.
612- // - EXTERNAL - data stored in an external location as described by external_data field.
613- enum DataLocation {
614- DEFAULT = 0;
615- EXTERNAL = 1;
616- }
617-
618- // If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
619- optional DataLocation data_location = 14;
620-
621- // For double
622- // Complex128 tensors are encoded as a single array of doubles,
623- // with the real components appearing in odd numbered positions,
624- // and the corresponding imaginary component appearing in the
625- // subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i]
626- // is encoded as [1.0, 2.0 ,3.0 ,4.0]
627- // When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
628- repeated double double_data = 10 [packed = true];
629-
630- // For uint64 and uint32 values
631- // When this field is present, the data_type field MUST be
632- // UINT32 or UINT64
633- repeated uint64 uint64_data = 11 [packed = true];
634-}
635-
636-// A serialized sparse-tensor value
637-message SparseTensorProto {
638- // The sequence of non-default values are encoded as a tensor of shape [NNZ].
639- // The default-value is zero for numeric tensors, and empty-string for string tensors.
640- // values must have a non-empty name present which serves as a name for SparseTensorProto
641- // when used in sparse_initializer list.
642- optional TensorProto values = 1;
643-
644- // The indices of the non-default values, which may be stored in one of two formats.
645- // (a) Indices can be a tensor of shape [NNZ, rank] with the [i,j]-th value
646- // corresponding to the j-th index of the i-th value (in the values tensor).
647- // (b) Indices can be a tensor of shape [NNZ], in which case the i-th value
648- // must be the linearized-index of the i-th value (in the values tensor).
649- // The linearized-index can be converted into an index tuple (k_1,...,k_rank)
650- // using the shape provided below.
651- // The indices must appear in ascending order without duplication.
652- // In the first format, the ordering is lexicographic-ordering:
653- // e.g., index-value [1,4] must appear before [2,1]
654- optional TensorProto indices = 2;
655-
656- // The shape of the underlying dense-tensor: [dim_1, dim_2, ... dim_rank]
657- repeated int64 dims = 3;
658-}
659-
660-// Defines a tensor shape. A dimension can be either an integer value
661-// or a symbolic variable. A symbolic variable represents an unknown
662-// dimension.
663-message TensorShapeProto {
664- message Dimension {
665- oneof value {
666- int64 dim_value = 1;
667- string dim_param = 2; // namespace Shape
668- };
669- // Standard denotation can optionally be used to denote tensor
670- // dimensions with standard semantic descriptions to ensure
671- // that operations are applied to the correct axis of a tensor.
672- // Refer to https://github.com/onnx/onnx/blob/main/docs/DimensionDenotation.md#denotation-definition
673- // for pre-defined dimension denotations.
674- optional string denotation = 3;
675- };
676- repeated Dimension dim = 1;
677-}
678-
679-// Types
680-//
681-// The standard ONNX data types.
682-message TypeProto {
683-
684- message Tensor {
685- // This field MUST NOT have the value of UNDEFINED
686- // This field MUST have a valid TensorProto.DataType value
687- // This field MUST be present for this version of the IR.
688- optional int32 elem_type = 1;
689- optional TensorShapeProto shape = 2;
690- }
691-
692- // repeated T
693- message Sequence {
694- // The type and optional shape of each element of the sequence.
695- // This field MUST be present for this version of the IR.
696- optional TypeProto elem_type = 1;
697- };
698-
699- // map<K,V>
700- message Map {
701- // This field MUST have a valid TensorProto.DataType value
702- // This field MUST be present for this version of the IR.
703- // This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
704- optional int32 key_type = 1;
705- // This field MUST be present for this version of the IR.
706- optional TypeProto value_type = 2;
707- };
708-
709- // wrapper for Tensor, Sequence, or Map
710- message Optional {
711- // The type and optional shape of the element wrapped.
712- // This field MUST be present for this version of the IR.
713- // Possible values correspond to OptionalProto.DataType enum
714- optional TypeProto elem_type = 1;
715- };
716-
717-
718- message SparseTensor {
719- // This field MUST NOT have the value of UNDEFINED
720- // This field MUST have a valid TensorProto.DataType value
721- // This field MUST be present for this version of the IR.
722- optional int32 elem_type = 1;
723- optional TensorShapeProto shape = 2;
724- }
725-
726-
727- oneof value {
728- // The type of a tensor.
729- Tensor tensor_type = 1;
730-
731- // NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
732- // as input and output to graphs and nodes. These types are needed to naturally
733- // support classical ML operators. DNN operators SHOULD restrict their input
734- // and output types to tensors.
735-
736- // The type of a sequence.
737- Sequence sequence_type = 4;
738-
739- // The type of a map.
740- Map map_type = 5;
741-
742- // The type of an optional.
743- Optional optional_type = 9;
744-
745-
746- // Type of the sparse tensor
747- SparseTensor sparse_tensor_type = 8;
748-
749- }
750-
751- // An optional denotation can be used to denote the whole
752- // type with a standard semantic description as to what is
753- // stored inside. Refer to https://github.com/onnx/onnx/blob/main/docs/TypeDenotation.md#type-denotation-definition
754- // for pre-defined type denotations.
755- optional string denotation = 6;
756-}
757-
758-// Operator Sets
759-//
760-// OperatorSets are uniquely identified by a (domain, opset_version) pair.
761-message OperatorSetIdProto {
762- // The domain of the operator set being identified.
763- // The empty string ("") or absence of this field implies the operator
764- // set that is defined as part of the ONNX specification.
765- // This field MUST be present in this version of the IR when referring to any other operator set.
766- optional string domain = 1;
767-
768- // The version of the operator set being identified.
769- // This field MUST be present in this version of the IR.
770- optional int64 version = 2;
771-}
772-
773-// Operator/function status.
774-enum OperatorStatus {
775- EXPERIMENTAL = 0;
776- STABLE = 1;
777-}
778-
779-message FunctionProto {
780- // The name of the function, similar usage of op_type in OperatorProto.
781- // Combined with FunctionProto.domain, this forms the unique identity of
782- // the FunctionProto.
783- optional string name = 1;
784-
785- // Deprecated since IR Version 8
786- // optional int64 since_version = 2;
787- reserved 2;
788- reserved "since_version";
789-
790- // Deprecated since IR Version 8
791- // optional OperatorStatus status = 3;
792- reserved 3;
793- reserved "status";
794-
795- // The inputs and outputs of the function.
796- repeated string input = 4;
797- repeated string output = 5;
798-
799- // The attribute parameters of the function.
800- // It is for function parameters without default values.
801- repeated string attribute = 6;
802-
803- // The attribute protos of the function.
804- // It is for function attributes with default values.
805- // A function attribute shall be represented either as
806- // a string attribute or an AttributeProto, not both.
807- repeated AttributeProto attribute_proto = 11;
808-
809- // The nodes in the function.
810- repeated NodeProto node = 7;
811- // A human-readable documentation for this function. Markdown is allowed.
812- optional string doc_string = 8;
813-
814- // The OperatorSets this function body (graph) relies on.
815- //
816- // All nodes in the function body (graph) will bind against the operator
817- // with the same-domain/same-op_type operator with the HIGHEST version
818- // in the referenced operator sets. This means at most one version can be relied
819- // for one domain.
820- //
821- // The operator sets imported by FunctionProto should be compatible with the ones
822- // imported by ModelProto. Example, if same operator set say 'A' is imported by FunctionProto
823- // and ModelProto then versions for the operator set may be different but,
824- // the operator schema returned for op_type, domain, version combination
825- // for both the versions should be same.
826-
827- repeated OperatorSetIdProto opset_import = 9;
828-
829- // The domain which this function belongs to. Combined with FunctionProto.name, this forms the unique identity of
830- // the FunctionProto.
831- optional string domain = 10;
832-}
833-
834-// For using protobuf-lite
835-option optimize_for = LITE_RUNTIME;
836-
modified tools/pnnx/src/pass_level5/fuse_multiheadattention.cpp +60 −0
@@ -1734,6 +1734,64 @@
17341734 }
17351735 };
17361736
1737+class fuse_multiheadattention_pass_onnx_1_2 : public fuse_multiheadattention_pass
1738+{
1739+public:
1740+ const char* match_pattern_graph() const
1741+ {
1742+ return R"PNNXIR(7767517
1743+21 20
1744+pnnx.Input input_q 0 1 input
1745+nn.Linear op_0 1 1 input 14 bias=%qkvbias in_features=%embed_dim out_features=%qkv_out_features @bias @weight
1746+Tensor.reshape op_1 1 1 14 15 shape=(%batch,%size,1,3,%embed_dim)
1747+Tensor.permute op_2 1 1 15 16 dims=(3,1,2,0,4)
1748+torch.squeeze op_3 1 1 16 17 dim=3
1749+torch.unbind op_4 1 3 17 18 19 20 dim=0
1750+Tensor.reshape op_5 1 1 18 21 shape=(%size,%num_heads,%feat_per_head)
1751+Tensor.reshape op_6 1 1 19 23 shape=(%size,%num_heads,%feat_per_head)
1752+Tensor.reshape op_7 1 1 20 25 shape=(%size,%num_heads,%feat_per_head)
1753+Tensor.permute op_8 1 1 21 22 dims=(1,0,2)
1754+Tensor.permute op_9 1 1 23 24 dims=(1,0,2)
1755+Tensor.permute op_10 1 1 25 26 dims=(1,0,2)
1756+Tensor.reshape op_11 1 1 22 27 shape=(%batch,%num_heads,%size,%feat_per_head)
1757+Tensor.reshape op_12 1 1 24 28 shape=(%batch,%num_heads,%size,%feat_per_head)
1758+Tensor.reshape op_13 1 1 26 29 shape=(%batch,%num_heads,%size,%feat_per_head)
1759+F.scaled_dot_product_attention op_14 3 1 27 28 29 35 dropout_p=0.000000e+00 is_causal=False
1760+Tensor.permute op_15 1 1 35 36 dims=(2,0,1,3)
1761+Tensor.reshape op_16 1 1 36 37 shape=(%size,%embed_dim)
1762+nn.Linear out_proj 1 1 37 38 bias=%outbias in_features=%embed_dim out_features=%embed_dim @bias @weight
1763+Tensor.reshape op_18 1 1 38 out shape=(%size,%batch,%embed_dim)
1764+pnnx.Output output 1 0 out
1765+)PNNXIR";
1766+ }
1767+
1768+ const char* replace_pattern_graph() const
1769+ {
1770+ return R"PNNXIR(7767517
1771+3 2
1772+pnnx.Input input 0 1 input
1773+nn.MultiheadAttention attention 1 1 input out embed_dim=%embed_dim kdim=%embed_dim vdim=%embed_dim num_heads=%num_heads batch_first=False add_zero_attn=False add_bias_kv=False
1774+pnnx.Output output 1 0 out
1775+)PNNXIR";
1776+ }
1777+
1778+ bool match(const std::map<std::string, const Operator*>& matched_operators, const std::map<std::string, Parameter>& captured_params, const std::map<std::string, Attribute>& /*captured_attrs*/) const
1779+ {
1780+ const int embed_dim = captured_params.at("embed_dim").i;
1781+ const int qkv_out_features = captured_params.at("qkv_out_features").i;
1782+ const int num_heads = captured_params.at("num_heads").i;
1783+ const int feat_per_head = captured_params.at("feat_per_head").i;
1784+
1785+ if (qkv_out_features != embed_dim * 3)
1786+ return false;
1787+
1788+ if (embed_dim != num_heads * feat_per_head)
1789+ return false;
1790+
1791+ return true;
1792+ }
1793+};
1794+
17371795 class fuse_multiheadattention_pass_onnx_2 : public fuse_multiheadattention_pass
17381796 {
17391797 public:
@@ -2048,6 +2106,7 @@
20482106 fuse_multiheadattention_pass_onnx onnx0;
20492107 fuse_multiheadattention_pass_onnx_1 onnx1;
20502108 fuse_multiheadattention_pass_onnx_1_1 onnx1a;
2109+ fuse_multiheadattention_pass_onnx_1_2 onnx1b;
20512110 fuse_multiheadattention_pass_onnx_2 onnx2;
20522111 fuse_multiheadattention_pass_onnx_3 onnx3;
20532112 fuse_multiheadattention_pass_onnx_4 onnx4;
@@ -2087,6 +2146,7 @@
20872146 pnnx_graph_rewrite(graph, &onnx0, opindex);
20882147 pnnx_graph_rewrite(graph, &onnx1, opindex);
20892148 pnnx_graph_rewrite(graph, &onnx1a, opindex);
2149+ pnnx_graph_rewrite(graph, &onnx1b, opindex);
20902150 pnnx_graph_rewrite(graph, &onnx2, opindex);
20912151 pnnx_graph_rewrite(graph, &onnx3, opindex);
20922152 pnnx_graph_rewrite(graph, &onnx4, opindex);
modified tools/pnnx/src/pass_onnx.cpp +1 −1
@@ -14,7 +14,7 @@
1414
1515 #include "pass_onnx.h"
1616
17-#include "onnx.pb.h"
17+#include "onnx-ml.pb.h"
1818
1919 #include <google/protobuf/io/coded_stream.h>
2020 #include <google/protobuf/io/zero_copy_stream_impl.h>
modified tools/pnnx/src/pass_onnx/canonicalize.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/dead_code_elimination.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/eliminate_noop.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/fold_constants.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/fuse_constant_as_attribute.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/inline_containers.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/inline_if_graph.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/model_stat.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/pass_onnx/nn_AdaptiveAvgPool2d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_AdaptiveAvgPool3d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_AvgPool2d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_AvgPool3d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_BatchNorm2d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_BatchNorm3d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_Conv2d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_Conv3d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_GELU.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_LayerNorm.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_Linear.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_MaxPool2d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_MaxPool3d.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/nn_MultiheadAttention.cpp +1 −1
@@ -15,7 +15,7 @@
1515 #include "pass_onnx.h"
1616 #include "ir.h"
1717
18-#include "onnx.pb.h"
18+#include "onnx-ml.pb.h"
1919
2020 namespace pnnx {
2121
modified tools/pnnx/src/pass_onnx/shape_inference.h +1 −1
@@ -12,7 +12,7 @@
1212 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313 // specific language governing permissions and limitations under the License.
1414
15-#include "onnx.pb.h"
15+#include "onnx-ml.pb.h"
1616
1717 namespace pnnx {
1818
modified tools/pnnx/src/save_onnx.cpp +1 −1
@@ -14,7 +14,7 @@
1414
1515 #include "save_onnx.h"
1616
17-#include "onnx.pb.h"
17+#include "onnx-ml.pb.h"
1818
1919 #include <string.h>
2020 #include <fstream>
modified tools/pnnx/tests/onnx/test_nn_ReLU.py +1 −1
@@ -61,7 +61,7 @@
6161 if not torch.allclose(a0, b0, 1e-4, 1e-4):
6262 return False
6363
64- if version.parse(torch.__version__) < version.parse('2.4'):
64+ if version.parse(torch.__version__) < version.parse('2.5'):
6565 return True
6666
6767 # export dynamo onnx
modified tools/pnnx/tests/onnx/test_squeezenet1_1.py +1 −1
@@ -39,7 +39,7 @@
3939 if not torch.allclose(a, b, 1e-4, 1e-4):
4040 return False
4141
42- if version.parse(torch.__version__) < version.parse('2.4'):
42+ if version.parse(torch.__version__) < version.parse('2.5'):
4343 return True
4444
4545 # export dynamo onnx
modified tools/pnnx/tests/onnx/test_swin_t.py +1 −1
@@ -43,7 +43,7 @@
4343 if not torch.allclose(a, b, 1e-4, 1e-4):
4444 return False
4545
46- if version.parse(torch.__version__) < version.parse('2.4'):
46+ if version.parse(torch.__version__) < version.parse('2.5'):
4747 return True
4848
4949 # export dynamo onnx
modified tools/pnnx/tests/onnx/test_vit_b_32.py +1 −1
@@ -46,7 +46,7 @@
4646 if not torch.allclose(a, b, 1e-4, 1e-4):
4747 return False
4848
49- if version.parse(torch.__version__) < version.parse('2.4'):
49+ if version.parse(torch.__version__) < version.parse('2.5'):
5050 return True
5151
5252 # export dynamo onnx