Skip to content

Conversation

eellison
Copy link
Contributor

@eellison eellison commented Mar 25, 2021

Stack from ghstack:

If we are running constant propagation on a graph that doesn't have any operators with constant inputs and any mutable inputs/outputs, we do not need to initialize an alias db. This is going to be used to speed up symbolic shape analysis.

Differential Revision: D27340863

@facebook-github-bot facebook-github-bot added oncall: jit Add this issue/PR to JIT oncall triage queue cla signed labels Mar 25, 2021
eellison added a commit that referenced this pull request Mar 25, 2021
ghstack-source-id: 97c5d7f
Pull Request resolved: #54640
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 25, 2021

💊 CI failures summary and remediations

As of commit 605a14b (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-scanned failure(s)

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@@ -274,12 +274,12 @@ struct ConstantPropagator {

i++; // increment bc we didn't remove current index
}
// an output was removed
return initial_outputs != true_block->outputs().size();
made_change_ |= initial_outputs != true_block->outputs().size();
Copy link
Member

Choose a reason for hiding this comment

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

I think it is safer to track whether replaceAndRemoveIfOutput (e.g., make it return bool) made changes to the graph to set made_change_. In the future if replaceAndRemoveIfOutput may alter the graph without changing the number of nodes, the code would still be correct.

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 dont know how realistic a scenario that removeExtraIfOutputs is going to add new outputs.. but i can make the change

} else {
aliasDb_ = nullptr;
}
aliasing_types_ = aliasing_types;
Copy link
Member

Choose a reason for hiding this comment

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

what's the rationale behind removing torch::make_unique?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's to lazy initialize alias db, since constructing it can be slow. if you're optimizing a graph with all scalars you dont need to access an aliasdb to constant propagate

@@ -300,6 +300,7 @@ struct ConstantPropagator {
loop_body->eraseOutput(loop_body_offset + i);
}
}
made_change_ |= initial_outputs != node->outputs().size();
Copy link
Member

Choose a reason for hiding this comment

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

Similar to above. It is better to set made_change_ = true when changes are made. This could be more robust if the transformation happens to alter the graph w/o changing the number of nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same question, do you think it's realistic that removeExtraLoopOutputs would ever add more outputs ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd hope not :-). But it also seems a bit more intuitive/safe to set made_change_ at the exact point where a change is made.

@eellison eellison requested a review from penguinwu March 25, 2021 18:37
Copy link
Contributor

@bertmaher bertmaher left a comment

Choose a reason for hiding this comment

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

lgtm!

If we are running constant propagation on a graph that doesn't have any operators with constant inputs and any mutable inputs/outputs, we do not need to initialize an alias db. This is going to be used to speed up symbolic shape analysis. 

[ghstack-poisoned]
If we are running constant propagation on a graph that doesn't have any operators with constant inputs and any mutable inputs/outputs, we do not need to initialize an alias db. This is going to be used to speed up symbolic shape analysis.

Differential Revision: [D27340863](https://our.internmc.facebook.com/intern/diff/D27340863)

[ghstack-poisoned]
eellison added a commit that referenced this pull request Mar 25, 2021
ghstack-source-id: 38099ff
Pull Request resolved: #54640
If we are running constant propagation on a graph that doesn't have any operators with constant inputs and any mutable inputs/outputs, we do not need to initialize an alias db. This is going to be used to speed up symbolic shape analysis.

Differential Revision: [D27340863](https://our.internmc.facebook.com/intern/diff/D27340863)

[ghstack-poisoned]
eellison added a commit that referenced this pull request Mar 26, 2021
ghstack-source-id: 158fb1b
Pull Request resolved: #54640
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #54640 (605a14b) into gh/eellison/173/base (68bdeef) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@                   Coverage Diff                    @@
##           gh/eellison/173/base   #54640      +/-   ##
========================================================
- Coverage                 77.44%   77.43%   -0.01%     
========================================================
  Files                      1893     1893              
  Lines                    186083   186085       +2     
========================================================
- Hits                     144108   144100       -8     
- Misses                    41975    41985      +10     

@facebook-github-bot
Copy link
Contributor

@eellison merged this pull request in 0e320dd.

@facebook-github-bot facebook-github-bot deleted the gh/eellison/173/head branch March 30, 2021 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants