Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We will have more tensor types like:
Some operator(FC e.g.) just process Tensor, when an
LODTensor
passed in as an input, FC assumes that the outputs are allTensor
s, but the framework should copy LOD info from inputs to outputs transparently, and make outputs LODTensors so that the LOD info will not be dropped.So, a type deducer is needed, it will get an operator's input tensor types and attributes, and deduce the outputs' tensor types.
We treat the type deducer a container of various deduce rules, and the type-deducer will only be used in
OperatorBase.InferShape
when the operators first visit the outputs.The new tensor-types will be free to add, with new deduce rules to help deduce the tensor types, for example:
A real whole deduce example:
RNN->FC
, FC will get more than oneLODTensor
s, and FC assumes the outputs areTensors
auto output1 = TypeDeducer<Tensor>(input_vars, op_attrs, var_name)
Tensor*
, butTypeDeducer
will make this output aLODTensor
in fact, and return theLODTensor.get_tensor()
This implementation is just a demo of the idea, and far from the actual usage.
Ignore the implementation of
LODTensor
, it is not finished and has another PR.