Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move map and sequence types to onnx domain, #2244

Merged
merged 13 commits into from
Sep 6, 2019

Conversation

linkerzhang
Copy link
Member

this is the first step of merging onnx-ml and onnx types.

@linkerzhang linkerzhang requested a review from a team as a code owner August 16, 2019 04:46
@linkerzhang
Copy link
Member Author

Merging ONNX and ONNX-ML IR was agreed in infra SIG meeting on 7/1/2019 as https://github.com/onnx/sigs/blob/master/infra/meetings/001-20190701.md. Especially for types, the difference between DNN and traditional ML can/will be shown by different op domains. there's no need having two different IR formats for the differentiation.

Copy link
Member

@bddppq bddppq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IR_VERSION needs to be bumped?

@linkerzhang
Copy link
Member Author

linkerzhang commented Aug 17, 2019

@bddppq IR version is bumped at most once for one ONNX release (following opset version bump policy). @gramalingam has already bumped the IR version to 6 when adding sparse tensor related support, so that, this PR does not need to bump IR version any more, make sense?

@prasanthpul prasanthpul added this to the 1.6 milestone Aug 19, 2019
message Sequence {
// The type and optional shape of each element of the sequence.
// This field MUST be present for this version of the IR.
optional TypeProto elem_type = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if we still need this comment here? If this can be optional indeed, we can use Sequence to export heterogeneous tensors of different datatypes also by keeping elem_type unspecified.

Copy link
Contributor

@wschin wschin Aug 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supporting heterogeneous tensors can probably be done by adding another type Tuple. Sequence stills sounds like a homogeneous type like IEnumerable<ElementType> in C#. This Sequence is for containing non-tensor elements with the same type like the predicted probabilities of all classes, [{"ClassA", 0.5, "ClassB", 0.25, "ClassC", 0.25}, {"ClassA", 1, "ClassB", 0, "ClassC", 0}].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe Spandan is talking about an unbounded list/sequence, but where the elements don't have the same type. I think there are some details concerning such a type worth sorting out first. E.g., do we just want a list of tensors of different types, or do we want truly heterogeneous lists (a list where some elements are tensors, other elements are lists of tensors, other elements are maps, etc.)? I guess it should be the later to be truly general-purpose. More importantly, we would need support for some form of dynamic-cast from untyped values to make use of such a type. I think it would be helpful to have a more comprehensive proposal (e.g., take a simple example with heterogeneous tensors and see what's required to support it).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short, I think we can do that generalization separately, so that this PR can be kept simple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think hetergeneous lists is a use case that we need to target. But I agree that it can designed separately to keep this PR simple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need heterogeneous types in one single variable, I'd personally consider a new type Tuple instead of Sequence. Sequence is more like a collection type where elements are not stored in consecutive memory blocks.


SparseTensor sparse_tensor_type = 8;

// #if ONNX-ML
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this can't be removed.

optional TensorShapeProto shape = 2;
}

// #if ONNX-ML
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line looks redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's not. see line 520 before.

onnx/onnx.proto Outdated

// The type of a map.
Map map_type = 5;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The type of sparse tensor. This type is different than tensor.


oneof value {
// The type of a tensor.
Tensor tensor_type = 1;

// NOTE: DNN-only implementations of ONNX MAY elect to not support non-tensor values
// as input and output to graphs and nodes. These types are needed to naturally
// support classical ML operators. DNN operators SHOULD restrict their input
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// support classical ML operators. DNN operators SHOULD restrict their input
// support classical ML operators. DNN operators SHOULD restrict their input

Copy link
Contributor

@wschin wschin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but please make sure the newly added lines' style is consistent with the old ones.

@BowenBao BowenBao mentioned this pull request Aug 22, 2019
5 tasks
linkerzhang and others added 2 commits August 21, 2019 18:08
Co-Authored-By: Wei-Sheng Chin <wschin@outlook.com>
Copy link
Member

@prasanthpul prasanthpul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onnx/onnx-ml.proto Outdated Show resolved Hide resolved
onnx/onnx-ml.proto3 Outdated Show resolved Hide resolved
onnx/onnx-operators-ml.proto Outdated Show resolved Hide resolved
onnx/onnx-ml.proto Outdated Show resolved Hide resolved
message SparseTensor {
// This field MUST NOT have the value of UNDEFINED
// repeated T
message Sequence {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a discussion to consider renaming this from Sequence to List or something like that

@prasanthpul prasanthpul added the ir label Aug 27, 2019
@linkerzhang
Copy link
Member Author

@prasanthpul given this PR is not merging ONNX-ML with ONNX, I'm not updating the docs to remove ONNX-ML concept.

@ebarsoum ebarsoum merged commit 2fdb3ef into onnx:master Sep 6, 2019
jcwchen pushed a commit to jcwchen/onnx that referenced this pull request Sep 23, 2020
Move map and sequence types to onnx domain, this is the first step of merging onnx-ml and onnx types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants