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

The Infer-shape process can be simplified #8088

Closed
JiayiFeng opened this issue Feb 2, 2018 · 0 comments · Fixed by #8087
Closed

The Infer-shape process can be simplified #8088

JiayiFeng opened this issue Feb 2, 2018 · 0 comments · Fixed by #8087
Assignees

Comments

@JiayiFeng
Copy link
Collaborator

JiayiFeng commented Feb 2, 2018

Now our shape inference is a very winding. Here is an example: to get some non-duplicatable input's dim in compile time, our program has to switch repeatedly between CompileTimeInferShapeContext and InferShapeContext. The call stack is like this:
(Calling from top to bottom)

DDim CompileTimeInferShapeContext::GetInputDim(string param_name);
  |
vector<DDim> InferShapeContext::GetInputsDim(string param_name);
  |
vector<DDim> InferShapeContext::GetDims(vectir<string> arg_name);
  |
DDim CompileTimeInferShapeContext::GetDim(string arg_name);
  |
DDim VerDesc::Shape();

What happens at runtime is similar, just replace CompileTimeInferShapeContext with RuntimeInferShapeContext.

There are at least two issues here:

  1. For a non-duplicatable input, the CompileTimeInferShapeContext::GetInputDim is invoked, while for a duplicatable input the InferShapeContext::GetInputsDim will be directly invoked. It mean's the entries of the same function dispersed in two class.
  2. vector<DDim> InferShapeContext::GetInputsDim(string param_name); is intended for duplicatable inputs. However, even the input is non-duplicatable, it will still be invoked indirectly. That is inefficient.

Solution:

Move the GetInputDim from CompileTimeInferShapeContext(and RunimeInferShapeContext) to InferShapeContext. And the GetInputDim invokes GetDim directly instead of detouring via GetInputsDim.

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 a pull request may close this issue.

1 participant