Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / mock_engine / stub_inference_engine.xpp
1 //
2 // Copyright 2016-2018 Intel Corporation.
3 //
4 // This software and the related documents are Intel copyrighted materials,
5 // and your use of them is governed by the express license under which they
6 // were provided to you (End User License Agreement for the Intel(R) Software
7 // Development Products (Version May 2017)). Unless the License provides
8 // otherwise, you may not use, modify, copy, publish, distribute, disclose or
9 // transmit this software or the related documents without Intel's prior
10 // written permission.
11 //
12 // This software and the related documents are provided as is, with no
13 // express or implied warranties, other than those that are expressly
14 // stated in the License.
15 //
16
17 #include <random>
18 #include <algorithm>
19
20 #include "stub_inference_engine.hpp"
21
22 using namespace InferenceEngine;
23 using namespace std;
24
25 void StubInferenceEngine::Infere(const Blob &input, Blob & output) {
26     unsigned int batchNumber = input.dims().size() > 3 ? input.dims()[3] : 1;
27     auto &outBlob = dynamic_cast<TBlob<float>&>(output);
28     outBlob.Resize({ 1000, batchNumber });
29     outBlob.allocate();
30     
31     //uniform distribution in 0-1 range
32     random_device rd;
33     mt19937 mersen(rd());
34     uniform_real_distribution<float> uniformDistribution(0 , 1);
35     generate(outBlob.data(), outBlob.data() + outBlob.size(), [&] () {
36         return uniformDistribution(mersen);
37     });
38 }
39