<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.1.0-dev</li>
<li>Operating System / Platform =&gt; Ubuntu x64 bionic 18.04.1</li>
<li>Compiler =&gt; gcc 8.0.1</li>
</ul>
<p dir="auto"><strong>Hello, There is a bug with dot product <a href=""><code class="notranslate">dot (InputArray m) const</code></a> when used in c++ implementation, But strangely this bug is not present in python implementation.</strong></p>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Check following python code:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; a  = np.zeros((5, 5),np.float32)
&gt;&gt;&gt; b = np.ones((5,1),np.float32)
&gt;&gt;&gt; a.dot(b)
array([[0.],
       [0.],
       [0.],
       [0.],
       [0.]], dtype=float32)"><pre class="notranslate">Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type <span class="pl-s"><span class="pl-pds">"</span>help<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>copyright<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>credits<span class="pl-pds">"</span></span> or <span class="pl-s"><span class="pl-pds">"</span>license<span class="pl-pds">"</span></span> <span class="pl-k">for</span> more information.
<span class="pl-k">&gt;&gt;&gt;</span> import numpy as np
<span class="pl-k">&gt;&gt;&gt;</span> a  <span class="pl-k">=</span> np.zeros<span class="pl-s"><span class="pl-pds">((</span><span class="pl-c1">5</span><span class="pl-k">,</span> <span class="pl-c1">5</span>)<span class="pl-k">,</span>np.float<span class="pl-c1">32</span>)</span>
<span class="pl-s"><span class="pl-k">&gt;&gt;&gt;</span> b <span class="pl-k">=</span> np.ones((<span class="pl-c1">5</span><span class="pl-k">,</span><span class="pl-c1">1</span>)<span class="pl-k">,</span>np.float<span class="pl-c1">32</span>)</span>
<span class="pl-s"><span class="pl-k">&gt;&gt;&gt;</span> a.dot(b)</span>
<span class="pl-s">array([[<span class="pl-c1">0</span>.],</span>
<span class="pl-s">       [<span class="pl-c1">0</span>.],</span>
<span class="pl-s">       [<span class="pl-c1">0</span>.],</span>
<span class="pl-s">       [<span class="pl-c1">0</span>.],</span>
<span class="pl-s">       [<span class="pl-c1">0</span>.]], dtype=float<span class="pl-c1">32</span>)</span></pre></div>
<p dir="auto">which works as expected.</p>
<p dir="auto">But when I tried to implement the same code in C++, it throws the following error everytime regardless of the case:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="abhishek@abhishek-HP-Pavilion-Notebook:~/testing$ ./test
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.0.1-dev) /home/abhishek/Downloads/opencv-master/modules/core/src/matmul.cpp:3274: error: (-215:Assertion failed) mat.size == size in function 'dot'

Aborted (core dumped)"><pre class="notranslate">abhishek@abhishek-HP-Pavilion-Notebook:<span class="pl-k">~</span>/testing$ ./test
terminate called after throwing an instance of <span class="pl-s"><span class="pl-pds">'</span>cv::Exception<span class="pl-pds">'</span></span>
  <span class="pl-en">what</span>():  OpenCV(4.0.1-dev) /home/abhishek/Downloads/opencv-master/modules/core/src/matmul.cpp:3274: error: (-215:Assertion failed) mat.size == size <span class="pl-k">in</span> <span class="pl-k">function</span> <span class="pl-en">'dot'</span>

Aborted (core dumped)</pre></div>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">The code I'm using for c++ is as below:</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="#include &lt;opencv2/opencv.hpp&gt;
#include &lt;iostream&gt;
#include &lt;cassert&gt;
#include &lt;fstream&gt;

int main(){
        cv::Mat a = cv::Mat::ones(5,5, CV_32F);
	cv::Mat b = cv::Mat::ones(5,1, CV_32F);
	cout &lt;&lt;  a.dot(b)  &lt;&lt; endl ;
	return 0; 
}"><pre class="notranslate">#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>opencv2/opencv.hpp<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>iostream<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>cassert<span class="pl-pds">&gt;</span></span>
#<span class="pl-k">include</span> <span class="pl-s"><span class="pl-pds">&lt;</span>fstream<span class="pl-pds">&gt;</span></span>

<span class="pl-k">int</span> <span class="pl-en">main</span>(){
        cv::Mat a = <span class="pl-c1">cv::Mat::ones</span>(<span class="pl-c1">5</span>,<span class="pl-c1">5</span>, CV_32F);
	cv::Mat b = <span class="pl-c1">cv::Mat::ones</span>(<span class="pl-c1">5</span>,<span class="pl-c1">1</span>, CV_32F);
	cout &lt;&lt;  a.<span class="pl-c1">dot</span>(b)  &lt;&lt; endl ;
	<span class="pl-k">return</span> <span class="pl-c1">0</span>; 
}</pre></div>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; 4.0.1, master branch <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/opencv/opencv/commit/e2dbf054ac5c54bd328f648d9d6146c09dfd5484/hovercard" href="https://github.com/opencv/opencv/commit/e2dbf054ac5c54bd328f648d9d6146c09dfd5484"><tt>e2dbf05</tt></a></li>
<li>Operating System / Platform =&gt; Windows 64 Bit</li>
<li>Compiler =&gt; Visual Studio 2017</li>
</ul>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">The compilation of the DNN module fails with several error C2398, e.g. due to the narrowing at line 106 in op_inf_engine.cpp<br>
netBuilder.connect(inpId, {layerId, i});<br>
possible fix<br>
netBuilder.connect(inpId, { static_castInferenceEngine::idx_t(layerId), static_castInferenceEngine::idx_t(i)});</p>
<p dir="auto">Affected files are</p>
<ul dir="auto">
<li>convolution_layer.cpp</li>
<li>pooling_layer.cpp</li>
<li>op_inf_engine.cpp</li>
</ul>