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

Support non-spatial mode in BatchNormalization #2092

Merged
merged 10 commits into from
Oct 15, 2019
Merged

Conversation

hariharans29
Copy link
Member

Description: Older opset spec of BatchNormalization supports non-spatial mode of the operator supported by some frameworks. This change supports that mode of operation.

Motivation and Context
Keep ORT backwards compatible

@hariharans29 hariharans29 requested a review from a team as a code owner October 11, 2019 02:08
@@ -532,7 +532,6 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
#endif

#ifdef USE_CUDA
broken_tests.insert({"mxnet_arcface", "result mismatch"});
Copy link
Member Author

Choose a reason for hiding this comment

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

Added to the exclusion list once above

@@ -319,7 +319,7 @@ private void TestMultiThreads()
private static Dictionary<string, string> GetSkippedModels()
{
var skipModels = new Dictionary<string, string>() {
{ "mxnet_arcface", "Model not supported by CPU execution provider" } ,
{ "mxnet_arcface", "Model is an invalid ONNX model",
Copy link
Member Author

Choose a reason for hiding this comment

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

See reply here on why it is invalid:
onnx/models#156

//constexpr int kMinCudaNumDims = 4;
//constexpr int kMaxCudaNumDims = 5;

if (X->Shape().GetDims().empty()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this check in favor of the more stricter check in line 20.

const Tensor* var,
bool is_spatial = true) {
const auto& x_dims = X->Shape().GetDims();
if (x_dims.size() < 2) {
Copy link
Member Author

@hariharans29 hariharans29 Oct 11, 2019

Choose a reason for hiding this comment

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

Even though, the spec doesn't explicitly state it, it makes sense if the minimum rank of 'X' is atleast 3 - N,C, and atleast one data dimension (D1). However, when we impose that, it seems to break some successfully running models that have input rank 2 - [N, C]. The implicit shape is [N, C, 1] in these cases and the results seem ok. Hence, modifying the minimum rank criteria to just 2. This is necessary to add as in the next step we parse the number of channels from the index position 1.

Copy link
Contributor

@HectorSVC HectorSVC left a comment

Choose a reason for hiding this comment

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

:shipit:

@hariharans29 hariharans29 merged commit 95ab5ad into master Oct 15, 2019
@hariharans29 hariharans29 deleted the BatchNormNonSpatial branch October 15, 2019 01:14
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.

2 participants