-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Design: infer_var_type #4795
Design: infer_var_type #4795
Conversation
Maybe we should also register InferShape to OpInfo @jacquesqiao |
|
||
The variable in our design can hold variant types. Such as `LoDTensor` and `SelectedRows`. An operator should be able to inference the variable types of its output. | ||
|
||
For example, a `lookup table` operator takes two `LoDTensor`; one is a float tensor as the embedding table, the other is an int tensor as word ID. The gradient operator of `lookup table` will generate a `SelectedRows` as its output. A `sum` operator can take both `LoDTensor` and `SelectedRows` as its inputs and will generate a `LoDTensor` if any of its inputs is `LoDTensor`, otherwise, the `sum` operator will generate `SelectedRows` as its output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my understanding, SelectedRows
is a LoDTensor
which stores word embeddings and a LoD which stores the sequence info and a seleted row ids
(may be a vector<int>
).
the LoDTensor
is supported by other ops already.
In my option, the selected row ids
is only used by lookup
and do not need to be exposed to other ops such as sum
, and no necessary to have a new data type that should be processed by ops besides LoDTensor
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a discussion with reyang, the new type SelectedRow
serves in scenarios such as sum the outputs of two lookup
.
It seems ok and there is no better way to support this currently.
7ed3ea6
to
f654810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InferVarType and InferShape are actually the same thing -- it should be called "Infer Type"
@wangkuiyi
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.