Skip to content

Commit 3924daf

Browse files
Carolyn Soofacebook-github-bot
Carolyn Soo
authored andcommitted
Expose stats_mode N for NaiveSyncBN
Summary: * Current code does not enable user to choose stats_mode="N" for naiveSyncBN. This change exposes that. - stats_mode="N" is necessary for supporting zero-length inputs. Without it: `SyncBatchNorm(stats_mode="") does not support zero batch size.` ------------------------ Reviewed By: jonmorton, vaibhava0, ppwwyyxx Differential Revision: D29362934 fbshipit-source-id: f8d5a33cac599f706e6620c31495e8c1577970dc
1 parent fefb626 commit 3924daf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

detectron2/layers/batch_norm.py

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def get_norm(norm, out_channels):
142142
# for debugging:
143143
"nnSyncBN": nn.SyncBatchNorm,
144144
"naiveSyncBN": NaiveSyncBatchNorm,
145+
# expose stats_mode N as an option to caller, required for zero-len inputs
146+
"naiveSyncBN_N": lambda channels: NaiveSyncBatchNorm(channels, stats_mode="N"),
145147
}[norm]
146148
return norm(out_channels)
147149

0 commit comments

Comments
 (0)