Skip to content

Commit 2fdb3ef

Browse files
linkerzhangebarsoum
authored andcommitted
move map and sequence types to onnx domain, (#2244)
Move map and sequence types to onnx domain, this is the first step of merging onnx-ml and onnx types.
1 parent 568b65a commit 2fdb3ef

File tree

6 files changed

+94
-54
lines changed

6 files changed

+94
-54
lines changed

docs/IR.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ The following types are used to define the types of graph and node inputs and ou
308308
|Variant | Type | Description |
309309
|---|---|---|
310310
ONNX|dense tensors|Tensors are a generalization of vectors and matrices; whereas vectors have one dimension, and matrices two, tensors can have any number of dimensions, including zero. A zero-dimensional tensor is logically equivalent to a scalar value.
311-
ONNX-ML|sequence|Sequences represent dense, ordered, collections of elements that are of homogeneous types.
312-
ONNX-ML|map|Maps represent associative tables, defined by a key type and a value type.
311+
ONNX|sequence|Sequences represent dense, ordered, collections of elements that are of homogeneous types.
312+
ONNX|map|Maps represent associative tables, defined by a key type and a value type.
313313

314314
ONNX currently does not define a sparse tensor type.
315315

onnx/onnx-ml.proto

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,6 @@ message TypeProto {
512512
optional TensorShapeProto shape = 2;
513513
}
514514

515-
message SparseTensor {
516-
// This field MUST NOT have the value of UNDEFINED
517-
// This field MUST have a valid TensorProto.DataType value
518-
// This field MUST be present for this version of the IR.
519-
optional int32 elem_type = 1;
520-
optional TensorShapeProto shape = 2;
521-
}
522-
523-
524515
// repeated T
525516
message Sequence {
526517
// The type and optional shape of each element of the sequence.
@@ -538,6 +529,15 @@ message TypeProto {
538529
optional TypeProto value_type = 2;
539530
};
540531

532+
533+
message SparseTensor {
534+
// This field MUST NOT have the value of UNDEFINED
535+
// This field MUST have a valid TensorProto.DataType value
536+
// This field MUST be present for this version of the IR.
537+
optional int32 elem_type = 1;
538+
optional TensorShapeProto shape = 2;
539+
}
540+
541541
message Opaque {
542542
// When missing, the domain is the same as the model's.
543543
optional string domain = 1;
@@ -553,7 +553,6 @@ message TypeProto {
553553
// The type of a tensor.
554554
Tensor tensor_type = 1;
555555

556-
557556
// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
558557
// as input and output to graphs and nodes. These types are needed to naturally
559558
// support classical ML operators. DNN operators SHOULD restrict their input
@@ -565,10 +564,11 @@ message TypeProto {
565564
// The type of a map.
566565
Map map_type = 5;
567566

568-
Opaque opaque_type = 7;
569567

570568
SparseTensor sparse_tensor_type = 8;
571-
569+
570+
Opaque opaque_type = 7;
571+
572572
}
573573

574574
// An optional denotation can be used to denote the whole

onnx/onnx-ml.proto3

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,6 @@ message TypeProto {
512512
TensorShapeProto shape = 2;
513513
}
514514

515-
message SparseTensor {
516-
// This field MUST NOT have the value of UNDEFINED
517-
// This field MUST have a valid TensorProto.DataType value
518-
// This field MUST be present for this version of the IR.
519-
int32 elem_type = 1;
520-
TensorShapeProto shape = 2;
521-
}
522-
523-
524515
// repeated T
525516
message Sequence {
526517
// The type and optional shape of each element of the sequence.
@@ -538,6 +529,15 @@ message TypeProto {
538529
TypeProto value_type = 2;
539530
};
540531

532+
533+
message SparseTensor {
534+
// This field MUST NOT have the value of UNDEFINED
535+
// This field MUST have a valid TensorProto.DataType value
536+
// This field MUST be present for this version of the IR.
537+
int32 elem_type = 1;
538+
TensorShapeProto shape = 2;
539+
}
540+
541541
message Opaque {
542542
// When missing, the domain is the same as the model's.
543543
string domain = 1;
@@ -553,7 +553,6 @@ message TypeProto {
553553
// The type of a tensor.
554554
Tensor tensor_type = 1;
555555

556-
557556
// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
558557
// as input and output to graphs and nodes. These types are needed to naturally
559558
// support classical ML operators. DNN operators SHOULD restrict their input
@@ -565,10 +564,11 @@ message TypeProto {
565564
// The type of a map.
566565
Map map_type = 5;
567566

568-
Opaque opaque_type = 7;
569567

570568
SparseTensor sparse_tensor_type = 8;
571-
569+
570+
Opaque opaque_type = 7;
571+
572572
}
573573

574574
// An optional denotation can be used to denote the whole

onnx/onnx.in.proto

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -509,16 +509,6 @@ message TypeProto {
509509
optional TensorShapeProto shape = 2;
510510
}
511511

512-
message SparseTensor {
513-
// This field MUST NOT have the value of UNDEFINED
514-
// This field MUST have a valid TensorProto.DataType value
515-
// This field MUST be present for this version of the IR.
516-
optional int32 elem_type = 1;
517-
optional TensorShapeProto shape = 2;
518-
}
519-
520-
// #if ONNX-ML
521-
522512
// repeated T
523513
message Sequence {
524514
// The type and optional shape of each element of the sequence.
@@ -536,6 +526,16 @@ message TypeProto {
536526
optional TypeProto value_type = 2;
537527
};
538528

529+
// #if ONNX-ML
530+
531+
message SparseTensor {
532+
// This field MUST NOT have the value of UNDEFINED
533+
// This field MUST have a valid TensorProto.DataType value
534+
// This field MUST be present for this version of the IR.
535+
optional int32 elem_type = 1;
536+
optional TensorShapeProto shape = 2;
537+
}
538+
539539
message Opaque {
540540
// When missing, the domain is the same as the model's.
541541
optional string domain = 1;
@@ -552,8 +552,6 @@ message TypeProto {
552552
// The type of a tensor.
553553
Tensor tensor_type = 1;
554554

555-
// #if ONNX-ML
556-
557555
// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
558556
// as input and output to graphs and nodes. These types are needed to naturally
559557
// support classical ML operators. DNN operators SHOULD restrict their input
@@ -565,10 +563,12 @@ message TypeProto {
565563
// The type of a map.
566564
Map map_type = 5;
567565

568-
Opaque opaque_type = 7;
566+
// #if ONNX-ML
569567

570568
SparseTensor sparse_tensor_type = 8;
571-
569+
570+
Opaque opaque_type = 7;
571+
572572
// #endif
573573
}
574574

onnx/onnx.proto

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,19 +510,39 @@ message TypeProto {
510510
optional TensorShapeProto shape = 2;
511511
}
512512

513-
message SparseTensor {
514-
// This field MUST NOT have the value of UNDEFINED
513+
// repeated T
514+
message Sequence {
515+
// The type and optional shape of each element of the sequence.
516+
// This field MUST be present for this version of the IR.
517+
optional TypeProto elem_type = 1;
518+
};
519+
520+
// map<K,V>
521+
message Map {
515522
// This field MUST have a valid TensorProto.DataType value
516-
// This field MUST be present for this version of the IR.
517-
optional int32 elem_type = 1;
518-
optional TensorShapeProto shape = 2;
519-
}
520-
523+
// This field MUST be present for this version of the IR.
524+
// This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
525+
optional int32 key_type = 1;
526+
// This field MUST be present for this version of the IR.
527+
optional TypeProto value_type = 2;
528+
};
529+
521530

522531
oneof value {
523532
// The type of a tensor.
524533
Tensor tensor_type = 1;
525534

535+
// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
536+
// as input and output to graphs and nodes. These types are needed to naturally
537+
// support classical ML operators. DNN operators SHOULD restrict their input
538+
// and output types to tensors.
539+
540+
// The type of a sequence.
541+
Sequence sequence_type = 4;
542+
543+
// The type of a map.
544+
Map map_type = 5;
545+
526546
}
527547

528548
// An optional denotation can be used to denote the whole

onnx/onnx.proto3

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,19 +510,39 @@ message TypeProto {
510510
TensorShapeProto shape = 2;
511511
}
512512

513-
message SparseTensor {
514-
// This field MUST NOT have the value of UNDEFINED
513+
// repeated T
514+
message Sequence {
515+
// The type and optional shape of each element of the sequence.
516+
// This field MUST be present for this version of the IR.
517+
TypeProto elem_type = 1;
518+
};
519+
520+
// map<K,V>
521+
message Map {
515522
// This field MUST have a valid TensorProto.DataType value
516-
// This field MUST be present for this version of the IR.
517-
int32 elem_type = 1;
518-
TensorShapeProto shape = 2;
519-
}
520-
523+
// This field MUST be present for this version of the IR.
524+
// This field MUST refer to an integral type ([U]INT{8|16|32|64}) or STRING
525+
int32 key_type = 1;
526+
// This field MUST be present for this version of the IR.
527+
TypeProto value_type = 2;
528+
};
529+
521530

522531
oneof value {
523532
// The type of a tensor.
524533
Tensor tensor_type = 1;
525534

535+
// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
536+
// as input and output to graphs and nodes. These types are needed to naturally
537+
// support classical ML operators. DNN operators SHOULD restrict their input
538+
// and output types to tensors.
539+
540+
// The type of a sequence.
541+
Sequence sequence_type = 4;
542+
543+
// The type of a map.
544+
Map map_type = 5;
545+
526546
}
527547

528548
// An optional denotation can be used to denote the whole

0 commit comments

Comments
 (0)