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

tensor type deduce #3110

Closed
wants to merge 6 commits into from
Closed

Conversation

Superjomn
Copy link
Contributor

@Superjomn Superjomn commented Jul 30, 2017

We will have more tensor types like:

  • Tensor
  • LODTensor
  • SparseTensor
  • SparseLOTTensor (maybe in the future)

Some operator(FC e.g.) just process Tensor, when an LODTensor passed in as an input, FC assumes that the outputs are all Tensors, 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:

  • LODTensor -> Tensor
  • SparseTensor -> Tensor

A real whole deduce example:

  • RNN->FC, FC will get more than one LODTensors, and FC assumes the outputs are Tensors
    • when FC needs output, it calls auto output1 = TypeDeducer<Tensor>(input_vars, op_attrs, var_name)
    • and get a Tensor*, but TypeDeducer will make this output a LODTensor in fact, and return the LODTensor.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.

@Superjomn Superjomn requested review from reyoung, a user and hedaoyuan July 30, 2017 10:34
@Superjomn Superjomn closed this Aug 10, 2017
heavengate pushed a commit to heavengate/Paddle that referenced this pull request Aug 16, 2021
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.

1 participant