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

Implement the type of data in channel #8285

Closed

Conversation

chengduoZH
Copy link
Contributor

fix #8284

kavyasrinet
kavyasrinet previously approved these changes Feb 8, 2018
@kavyasrinet kavyasrinet dismissed their stale review February 9, 2018 00:04

Need to update comment

Copy link

@kavyasrinet kavyasrinet left a comment

Choose a reason for hiding this comment

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

Thanks so much for making this PR! I just have a few questions I have posted.

SELECTED_ROWS = 10;
LOD_TENSOR_ARRAY = 11;
}
required DataType base_type = 1;

Choose a reason for hiding this comment

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

From what I understand, base_type would be the channel type (type of elements in channel) right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, the type of element in the channel should be repeated MetaDataDesc.
For example, the type of element is <int32, int64, float32>.

optional bool data_bool = 2;
optional int32 data_int32 = 3;
optional int64 data_int64 = 4;
optional float data_float = 5;

Choose a reason for hiding this comment

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

where would these fields be used ? As attributes for MetaDataDesc ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these fields are attributes of MetaDataDesc and are optional, so one MetaDataDesc only describes one base_type.

optional LoDTensorArrayDesc tensor_array = 8;
}

message ChanEleDesc { repeated MetaDataDesc meta_data = 1; }
Copy link

@kavyasrinet kavyasrinet Feb 9, 2018

Choose a reason for hiding this comment

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

I assume this step would append multiple elements in the tuple together ? and the next step would append tuples of these ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can regard the ChanEleDesc as a tuple, it can describe <int32,int32,int64,float32>.

@@ -118,6 +118,38 @@ message LoDTensorArrayDesc {

message ReaderDesc { repeated LoDTensorDesc lod_tensor = 1; }

message MetaDataDesc {
enum DataType {
BOOL = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you. I see based on the discussion we had on Hi yesterday, you have included the basic data types as well.

}
required DataType base_type = 1;
optional bool data_bool = 2;
optional int32 data_int32 = 3;
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 not sure what will we save in these optionals for fundamental types? Could you please explain with an example. For example, if we make a channel which can take tuple of 2 integers, how will this look?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can define a visitor, and the visitor can get the data of MetaData according to the data type.

message ChanEleDesc { repeated MetaDataDesc meta_data = 1; }

message ChanDesc {
repeated ChanEleDesc channel_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.

Could you also explain why ChanEleDesc is repeated here? From what I understand, the types of each of the dimensions in the n-tuple is captured by the statement repeated MetaDataDesc meta_data. Are we trying to make a tuple of tuples here? Sorry about the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know what you mean, let me think again.

TENSOR = 8;
LOD_TENSOR = 9;
SELECTED_ROWS = 10;
LOD_TENSOR_ARRAY = 11;
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 not sure how we will be able to support channel of type channel. Go allows this. Do you think this code would suffice for that? Also, I am not sure if we need it right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good question, I think that we should also support channel of type channel, but this code maybe should be changed.

message ChanEleDesc { repeated VarDesc meta_data = 1; }

message ChanDesc {
repeated ChanEleDesc channel_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 think ChanEleDesc maybe not needed, each element inside one channel instance should be of the same type. So the ChanDesc should look like:

message ChanDesc {
required VarType ele_type = 1;
required int32 cap = 2 [ default = 0 ];
required string name = 3;
}

Then VarType should have a new type called VAR_LIST representing a list of variables, so that element like tensor, label is able to put inside the channel.

The contents of the channel are manipulated at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@typhoonzero thanks for your review! And this is a good suggestion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think all the work to do in this PR is to add the following definition of ChannelDesc:

message ChannelDesc {
  VarDesc elem_type = 1;
  int cap = 2;
}

Nothing more than that.

message ChanDesc {
repeated ChanEleDesc channel_type = 1;
required int32 cap = 2 [ default = 0 ];
required string name = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why would we need name here. I can see that we do need cap.

A reference design is the Go's channel definition: https://github.com/golang/go/blob/4fc9565ffce91c4299903f7c17a275f0786734a1/src/runtime/chan.go#L17-L29

We are particularly interested in elemtype.

@CLAassistant
Copy link

CLAassistant commented Feb 10, 2018

CLA assistant check
All committers have signed the CLA.

@chengduoZH chengduoZH closed this Feb 11, 2018
@chengduoZH
Copy link
Contributor Author

This PR is not mature enough, and it is turned off first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the type of data in channel
6 participants