Skip to content

Update Dropout and BatchNorm to be Training Friendly#2568

Merged
wschin merged 23 commits intoonnx:masterfrom
lara-hdr:lahaidar/update_training_ops
Feb 6, 2020
Merged

Update Dropout and BatchNorm to be Training Friendly#2568
wschin merged 23 commits intoonnx:masterfrom
lara-hdr:lahaidar/update_training_ops

Conversation

@lara-hdr
Copy link
Copy Markdown
Contributor

@lara-hdr lara-hdr commented Jan 23, 2020

Initial PR: #1887
This PR updates Dropout and BatchNormalization to be training friendly.

For Dropout:
The "ratio" is now an input rather than an attribute of the operator, and a new attribute "seed" is introduced.

For BatchNormalization:
The operator already have support for the mean and var as inputs/outputs and saved_mean and saved_var as output of the model. The input mean and var will be the running values if we are in training mode, otherwise they will be the estimated values. The optional outputs mean/var/saved_mean/saved_var will only be used in training mode.
A new optional input "training_mode" is introduced and defaults to False since in most cases we would export ONNX models in inference mode; this is an input rather than an attribute since we need to modify it during the runtime.
The new attribute "training_mode" would allow to state explicitly if the operator is in training or inference mode. However the backend engine running the ONNX model could infer this information from the ONNX model, so we could potentially remove this attribute completely, and let the engine decide how to compute the output of this operator.

@lara-hdr lara-hdr requested a review from a team as a code owner January 23, 2020 18:24
@lara-hdr
Copy link
Copy Markdown
Contributor Author

@SherlockNoMad @wschin for review

@lara-hdr lara-hdr requested a review from a team as a code owner January 24, 2020 23:25
Comment thread onnx/defs/nn/defs.cc
Comment thread onnx/defs/nn/defs.cc
Comment thread onnx/defs/nn/defs.cc
Comment thread onnx/defs/nn/defs.cc
Comment thread docs/Operators.md
Comment thread docs/Operators.md Outdated
Comment thread docs/Operators.md
Comment thread docs/Changelog.md Outdated
Comment thread docs/Changelog.md Outdated
Comment thread docs/Changelog.md Outdated
Comment thread docs/Changelog.md
Comment thread docs/Changelog.md Outdated
Comment thread docs/Operators.md Outdated
Comment thread docs/Changelog.md Outdated
Comment thread docs/Changelog.md Outdated
Comment thread docs/Changelog.md Outdated
@wschin wschin requested a review from a team January 30, 2020 17:32
@lara-hdr
Copy link
Copy Markdown
Contributor Author

@gramalingam for review

Copy link
Copy Markdown
Contributor

@SherlockNoMad SherlockNoMad left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment thread onnx/defs/nn/defs.cc
Comment thread onnx/defs/nn/defs.cc
@lara-hdr
Copy link
Copy Markdown
Contributor Author

lara-hdr commented Jan 31, 2020

@prasanthpul prasanthpul added the topic: operator Issues related to ONNX operators label Feb 1, 2020
@lara-hdr
Copy link
Copy Markdown
Contributor Author

lara-hdr commented Feb 5, 2020

@ebarsoum CI is green. Thanks!

@wschin wschin merged commit 8b3f7e2 into onnx:master Feb 6, 2020
@winnietsang winnietsang added this to the 1.7 milestone Feb 13, 2020
facebook-github-bot pushed a commit to pytorch/pytorch that referenced this pull request Mar 27, 2020
Summary:
- Update Dropout and Batchnorm in opset 12 : onnx/onnx#2568
- Update api logic for exporting to ONNX training amenable models
Pull Request resolved: #32950

Reviewed By: hl475

Differential Revision: D19710370

Pulled By: houseroad

fbshipit-source-id: e5e79d38552936966662c41d39ddf33be1ba3e35
lara-hdr added a commit to lara-hdr/pytorch that referenced this pull request Mar 27, 2020
)

Summary:
- Update Dropout and Batchnorm in opset 12 : onnx/onnx#2568
- Update api logic for exporting to ONNX training amenable models
Pull Request resolved: pytorch#32950

Reviewed By: hl475

Differential Revision: D19710370

Pulled By: houseroad

fbshipit-source-id: e5e79d38552936966662c41d39ddf33be1ba3e35
jcwchen pushed a commit to jcwchen/onnx that referenced this pull request Sep 23, 2020
* Update Dropout and  BatchNorm to be Training Friendly

* fix test name

* update ref implementation

* merge with master and re-generate docs

* fix eliminate dropout test

* missing type annotation

* update doc + shape inference

* update doc

* re-gen doc

* update doc

* update doc

* fxitest

* add hasInputShape check

* rename outputs + update doc

* static_cast for stricter CI

Co-authored-by: Wei-Sheng Chin <wechi@microsoft.com>
Co-authored-by: Emad Barsoum <ebarsoum@gmail.com>
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
)

Summary:
- Update Dropout and Batchnorm in opset 12 : onnx/onnx#2568
- Update api logic for exporting to ONNX training amenable models
Pull Request resolved: pytorch#32950

Reviewed By: hl475

Differential Revision: D19710370

Pulled By: houseroad

fbshipit-source-id: e5e79d38552936966662c41d39ddf33be1ba3e35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: operator Issues related to ONNX operators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants