Repository: opencv
Issue: DNN now predicts incorrectly in Universal Windows Platform build
Labels: bug,priority: low,platform: winrt/uwp,category: dnn,Hackathon

- OpenCV => 3.3.0-rc
- Operating System / Platform =>Windows 10 - 64 bit
- Compiler =>Visual Studio 15 2017
- cmake => 3.8.2

##### Detailed description

Using the following [dnn code example](http://www.docs.opencv.org/trunk/d5/de7/tutorial_dnn_googlenet.html) with a win32 build of opencv `3.3.0-rc` produces correct predictions/classifications with both the Debug and Release binaries, and in x86_64 and x86 builds.  However, running the same code in a Universal Windows Platform build (where the APPCONTAINER bit is set) using the same model (GoogLeNet), and input image (`space_shuttle.jpg` from the example in the wiki), produces different results. The version of the DNN module shipped with `3.2.0` opencv_contrib outputs correct probabilities in both win32 and UWP however. Below are the probability matrixes produced in 3.3.0-rc:

- Using the x86 and the x86_64 UWP Debug binaries, the probability matrix `prob` is filled with zeros and a class prediction of `342`:
>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

- Using the x86 and the x86_64 UWP Release binaries, the probability matrix `prob` is filled with incorrect values, and a class prediction of `693`:
> [131, 227, 76, 58, 87, 222, 194, 58, 43, 119, 215, 58, 33, 191, 231, 58, 92, 3, 234, 58, 113, 151, 6, 59, 239, 148, 243, 58, 190, 124, 103, 59, 47, 20, 145, 59, 126, 70, 84, 59, 205, 235, 51, 59, 108, 31, 38, 59, 79, 62, 217, 58, 82, 61, 143, 58, 1, 244, 193, 58, 30, 183, 205, 58, 3, 252, 187, 58, 38, 42, 236, 58, 31, 154, 30, 59, 56, 228, 20, 59, 0, 132, 11, 59, 177, 168, 87, 59, 62, 181, 131, 59, 109, 50, 96, 59, 69, 43, 61, 59, 54, 132, 54, 59, 230, 94, 20, 59, 97, 200, 181, 58, 53, 105, 53, 59, 155, 11, 58, 59, 32, 242, 15, 59, 143, 25, 242, 58, 134, 232, 242, 58, 146, 199, 253, 58, 39, 25, 14, 59, 67, 250, 97, 59, 36, 74, 92, 59, 219, 39, 80, 59, 68, 211, 114, 59, 130, 73, 87, 59, 32, 73, 42, 59, 203, 202, 246, 58, 44, 249, 115, 59, 92, 191, 64, 59, 138, 206, 93, 59, 1, 2, 30, 59, 21, 176, 4, 59, 91, 28, 199, 58, 248, 125, 241, 58, 231, 197, 96, 58, 88, 252, 136, 58, 138, 41, 175, 58, 246, 229, 197, 58, 210, 194, 184, 58, 88, 112, 170, 58, 93, 164, 145, 58, 159, 224, 210, 58, 163, 16, 206, 58, 46, 62, 165, 58, 248, 11, 230, 58, 109, 236, 188, 58, 98, 56, 145, 58, 83, 37, 117, 58, 42, 226, 163, 58, 182, 127, 159, 58, 233, 22, 239, 58, 52, 172, 68, 59, 44, 219, 81, 59, 120, 77, 58, 59, 174, 222, 250, 58, 188, 191, 21, 59, 90, 91, 51, 59, 92, 164, 74, 59, 176, 88, 83, 59, 228, 216, 23, 59, 121, 61, 239, 58, 3, 240, 221, 58, 235, 233, 212, 58, 4, 221, 20, 59, 29, 1, 21, 59, 10, 122, 14, 59, 83, 107, 242, 58, 176, 242, 58, 59, 64, 157, 15, 59, 163, 174, 52, 59, 46, 211, 72, 59, 48, 165, 30, 59, 209, 98, 241, 58, 68, 241, 179, 58, 238, 109, 195, 58, 89, 31, 192, 58, 66, 90, 197, 58, 216, 85, 6, 59, 44, 1, 51, 59, 38, 201, 65, 59, 142, 245, 71, 59, 242, 19, 73, 59, 204, 81, 37, 59, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 167, 240, 43, 58, 137, 234, 135, 58, 216, 163, 107, 58, 99, 164, 74, 58, 220, 255, 48, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 194, 58, 49, 58, 27, 108, 57, 58, 61, 197, 45, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 79, 151, 17, 58, 157, 72, 42, 58, 131, 213, 35, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 209, 235, 21, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 141, 130, 42, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 126, 126, 33, 58, 215, 102, 9, 58, 161, 221, 39, 58, 174, 114, 37, 58, 215, 102, 9, 58, 215, 102, 9, 58, 122, 254, 18, 58, 53, 206, 127, 58, 101, 25, 109, 58, 219, 210, 61, 58, 238, 48, 25, 58, 125, 87, 11, 58, 73, 220, 14, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 16, 209, 39, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 112, 84, 32, 58, 193, 103, 63, 58, 211, 167, 127, 58, 218, 197, 52, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 84, 5, 36, 58, 244, 212, 46, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 215, 102, 9, 58, 247, 127, 68, 58, 56, 156, 150, 58, 33, 163, 181, 58, 245, 216, 138, 58, 19, 58, 91, 58, 115, 39, 32, 58]

- The win32 binaries, which predict correctly class `812` for space shuttle, has the following probability matrix:
> [221, 219, 55, 43, 225, 109, 178, 44, 24, 114, 131, 45, 174, 158, 99, 45, 21, 162, 159, 45, 58, 236, 167, 44, 13, 110, 207, 41, 151, 24, 130, 45, 63, 46, 61, 45, 128, 213, 191, 41, 208, 103, 75, 44, 244, 37, 183, 44, 48, 188, 222, 45, 44, 38, 139, 44, 15, 232, 246, 44, 143, 95, 32, 46, 87, 132, 57, 43, 229, 254, 139, 46, 189, 208, 76, 47, 94, 162, 150, 45, 10, 119, 248, 44, 152, 196, 3, 45, 216, 15, 246, 45, 212, 220, 225, 46, 7, 94, 200, 45, 13, 64, 60, 45, 32, 75, 212, 45, 193, 46, 11, 45, 112, 241, 210, 44, 135, 192, 109, 46, 89, 20, 225, 42, 176, 2, 252, 45, 68, 158, 29, 44, 248, 218, 136, 43, 183, 235, 6, 45, 141, 14, 101, 44, 137, 23, 85, 46, 129, 215, 234, 43, 13, 1, 110, 43, 78, 135, 42, 45, 143, 50, 200, 44, 90, 68, 200, 44, 56, 207, 161, 44, 150, 27, 243, 44, 202, 160, 59, 46, 131, 43, 88, 42, 30, 201, 93, 44, 190, 189, 241, 47, 223, 178, 254, 43, 35, 237, 82, 45, 190, 147, 72, 45, 206, 134, 226, 48, 13, 20, 67, 43, 228, 249, 136, 42, 224, 74, 143, 43, 253, 188, 45, 42, 44, 254, 127, 42, 116, 77, 148, 41, 70, 197, 128, 43, 34, 82, 196, 42, 64, 56, 223, 42, 238, 206, 50, 44, 61, 52, 125, 44, 215, 139, 119, 40, 10, 75, 176, 43, 7, 105, 117, 43, 11, 142, 113, 45, 213, 1, 90, 42, 156, 207, 52, 43, 214, 184, 52, 43, 1, 138, 34, 42, 74, 224, 183, 43, 94, 225, 143, 44, 1, 168, 211, 45, 12, 45, 150, 44, 14, 127, 220, 42, 135, 72, 188, 43, 219, 118, 149, 45, 14, 130, 12, 45, 230, 169, 174, 42, 28, 38, 96, 46, 203, 114, 100, 45, 73, 5, 130, 43, 104, 203, 209, 45, 149, 205, 28, 45, 29, 28, 175, 45, 2, 91, 129, 43, 55, 25, 75, 46, 42, 168, 218, 44, 59, 148, 148, 48, 36, 177, 178, 43, 18, 9, 236, 45, 150, 40, 2, 43, 32, 84, 133, 43, 12, 84, 211, 47, 36, 114, 12, 45, 101, 133, 203, 45, 234, 244, 139, 44, 58, 53, 12, 43, 235, 255, 161, 46, 85, 71, 47, 44, 26, 128, 172, 42, 92, 157, 18, 41, 115, 231, 47, 45, 44, 145, 92, 45, 42, 191, 159, 41, 107, 98, 34, 44, 208, 128, 133, 43, 196, 248, 145, 40, 90, 171, 25, 41, 60, 123, 189, 42, 86, 173, 179, 44, 156, 229, 189, 47, 174, 199, 181, 45, 100, 134, 34, 47, 182, 26, 81, 46, 246, 27, 65, 41, 152, 254, 16, 43, 157, 232, 203, 42, 147, 156, 11, 42, 229, 56, 34, 46, 57, 223, 123, 43, 217, 219, 4, 44, 194, 214, 14, 43, 176, 184, 81, 46, 123, 86, 173, 42, 81, 84, 156, 44, 52, 147, 157, 46, 223, 29, 83, 45, 141, 119, 168, 47, 222, 42, 132, 43, 100, 207, 199, 43, 250, 225, 140, 47, 107, 239, 129, 42, 10, 29, 114, 45, 10, 117, 160, 44, 246, 163, 99, 44, 132, 188, 185, 42, 125, 153, 245, 43, 212, 47, 39, 43, 214, 65, 206, 44, 23, 92, 19, 44, 23, 16, 48, 43, 154, 217, 97, 46, 238, 103, 218, 50, 10, 96, 187, 43, 199, 92, 19, 47, 252, 9, 86, 46, 133, 101, 154, 49, 231, 15, 50, 45, 102, 49, 15, 47, 57, 94, 28, 46, 4, 86, 88, 45, 145, 31, 136, 43, 106, 15, 143, 44, 94, 180, 225, 42, 200, 140, 139, 44, 206, 248, 13, 45, 54, 78, 144, 46, 236, 211, 100, 43, 86, 57, 15, 44, 193, 27, 34, 44, 135, 54, 17, 42, 235, 59, 33, 43, 155, 250, 6, 45, 71, 130, 218, 44, 120, 188, 22, 43, 155, 247, 148, 42, 76, 255, 138, 43, 141, 93, 167, 44, 131, 85, 33, 43, 153, 164, 148, 43, 192, 221, 169, 42, 64, 88, 146, 46, 182, 15, 21, 45, 103, 138, 208, 43, 185, 163, 12, 42, 185, 247, 64, 44, 17, 195, 141, 43, 17, 18, 134, 42, 126, 218, 31, 42, 239, 6, 133, 45, 5, 76, 181, 41, 63, 106, 158, 45, 114, 208, 129, 45, 177, 149, 162, 46, 156, 230, 17, 47, 167, 145, 148, 43, 201, 244, 55, 46, 98, 240, 55, 44, 69, 195, 83, 47, 52, 10, 200, 42, 188, 148, 60, 46, 248, 81, 119, 44, 90, 201, 101, 45, 116, 81, 20, 46, 17, 102, 34, 44, 96, 103, 10, 45, 242, 172, 205, 43, 237, 103, 129, 46, 205, 140, 2, 42, 91, 166, 136, 45, 26, 115, 171, 43, 241, 66, 191, 47, 28, 57, 65, 43, 52, 175, 228, 45, 36, 200, 75, 44, 175, 3, 138, 44, 4, 41, 178, 44, 25, 105, 157, 41, 253, 176, 207, 42, 108, 127, 160, 45, 211, 70, 66, 47, 97, 48, 141, 44, 239, 62, 203, 44, 152, 96, 80, 44, 229, 205, 102, 47, 29, 110, 205, 45, 158, 255, 35, 43, 5, 59, 204, 44, 221, 60, 128, 45, 214, 242, 136, 43, 31, 186, 23, 47, 39, 57, 38, 48, 54, 8, 98, 45, 124, 189, 164, 42, 218, 44, 49, 43, 100, 229, 72, 47, 190, 0, 103, 45, 64, 133, 102, 43, 23, 76, 67, 43, 114, 251, 188, 46, 67, 132, 198, 43, 231, 176, 240, 42, 151, 82, 210, 43, 222, 161, 105, 45, 114, 231, 20, 44, 32, 76, 236, 44, 43, 98, 236, 42, 144, 217, 197, 43, 244, 137, 196, 42, 230, 85, 118, 43, 178, 183, 56, 43, 167, 124, 13, 43, 60, 35, 199, 42, 56, 106, 62, 46, 190, 39, 1, 43, 82, 114, 201, 42, 158, 158, 104, 46, 47, 93, 139, 44]

I have verified that the model appears to be loading correctly by checking to make sure all the layers are the same in both the win32 and UWP builds. The input image / matrix is also identical in both win32 and UWP.