You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2018/04/27 06:00:19 UTC

[incubator-mxnet] branch master updated (301ea63 -> 1d33fc7)

This is an automated email from the ASF dual-hosted git repository.

jxie pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git.


    from 301ea63  Update mobilenetv2 symbol definition (#10595)
     new 0a664ef  test inference multiple times.
     new 76a1029  Fix a bug in GetMKLDNNData().
     new d62f138  Update comments.
     new a1cb6a6  Handle all cases for GetMKLDNNDataReorder
     new 3713ead  avoid unnecessary message.
     new 29cd215  Add C++ unit test for NDArray.
     new deeeea4  Fix a minor bug.
     new 7d6e8e0  Unit tests on GetMKLDNNDataReorder.
     new 9d1b9dc  Fix lint error.
     new 2bd6691  Add more test cases.
     new 99bd17f  add comments for the test code.
     new 9e90090  Reorganize test code.
     new 07819ad  test in jenkins.
     new 6085831  Fix jenkins.
     new e554999  Fix Jenkins.
     new 652a895  test jenkins.
     new 1d33fc7  test Jenkins.

The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Jenkinsfile                                  |   5 +-
 src/ndarray/ndarray.cc                       |  48 ++++--
 src/operator/nn/mkldnn/mkldnn_base-inl.h     |  31 +++-
 src/operator/nn/mkldnn/mkldnn_base.cc        |  12 +-
 tests/cpp/operator/mkldnn.cc                 | 248 +++++++++++++++++++++++++++
 tests/python/gpu/test_gluon_model_zoo_gpu.py |  19 +-
 6 files changed, 329 insertions(+), 34 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 13/17: test in jenkins.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 07819ad72268370b459b42f4f7b6a011c5dfcdfe
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sun Apr 22 08:35:06 2018 +0000

    test in jenkins.
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 5601c52..cc04808 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -568,7 +568,7 @@ try {
         ws('workspace/ut-cpp-gpu') {
           timeout(time: max_time, unit: 'MINUTES') {
             init_git()
-            unpack_lib('cmake_gpu', mx_cmake_lib)
+            unpack_lib('cmake_mkldnn_gpu', mx_cmake_lib)
             sh "ci/build.py --nvidiadocker --platform ubuntu_gpu /work/runtime_functions.sh unittest_ubuntu_gpu_cpp"
           }
         }

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 01/17: test inference multiple times.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 0a664ef842f5c3ecc9400af2e37921b2a81b49fb
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Wed Apr 18 06:37:47 2018 +0000

    test inference multiple times.
---
 tests/python/gpu/test_gluon_model_zoo_gpu.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tests/python/gpu/test_gluon_model_zoo_gpu.py b/tests/python/gpu/test_gluon_model_zoo_gpu.py
index 378a822..273ad3d 100644
--- a/tests/python/gpu/test_gluon_model_zoo_gpu.py
+++ b/tests/python/gpu/test_gluon_model_zoo_gpu.py
@@ -81,15 +81,16 @@ def test_inference():
             gpu_param = gpu_params.get(k)
             gpu_param.set_data(cpu_param.data().as_in_context(mx.gpu()))
 
-        # Run inference.
-        with autograd.record(train_mode=False):
-            cpu_out = cpu_model(mx.nd.array(data, ctx=mx.cpu()))
-            gpu_out = gpu_model(gpu_data)
-        out = cpu_out.asnumpy()
-        max_val = np.max(np.abs(out))
-        gpu_max_val = np.max(np.abs(gpu_out.asnumpy()))
-        eprint(model_name + ": CPU " + str(max_val) + ", GPU " + str(gpu_max_val))
-        assert_almost_equal(out / max_val, gpu_out.asnumpy() / max_val, rtol=1e-3, atol=1e-3)
+        for i in range(5):
+            # Run inference.
+            with autograd.record(train_mode=False):
+                cpu_out = cpu_model(mx.nd.array(data, ctx=mx.cpu()))
+                gpu_out = gpu_model(gpu_data)
+            out = cpu_out.asnumpy()
+            max_val = np.max(np.abs(out))
+            gpu_max_val = np.max(np.abs(gpu_out.asnumpy()))
+            eprint(model_name + ": CPU " + str(max_val) + ", GPU " + str(gpu_max_val))
+            assert_almost_equal(out / max_val, gpu_out.asnumpy() / max_val, rtol=1e-3, atol=1e-3)
 
 def get_nn_model(name):
     if "densenet" in name:

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 02/17: Fix a bug in GetMKLDNNData().

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 76a102989af0c4b635083437b9ef133435710fd8
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Fri Apr 20 01:21:32 2018 +0000

    Fix a bug in GetMKLDNNData().
---
 src/ndarray/ndarray.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ndarray/ndarray.cc b/src/ndarray/ndarray.cc
index b428c2c..533d2be 100644
--- a/src/ndarray/ndarray.cc
+++ b/src/ndarray/ndarray.cc
@@ -568,8 +568,11 @@ const mkldnn::memory *NDArray::GetMKLDNNData() const {
   CHECK(storage_type() == kDefaultStorage);
   // If this array uses MKLDNN layout, we have to make sure it's not a view.
   // Otherwise, we'll have to change the layout inside the array.
-  if (IsMKLDNNData())
+  if (IsMKLDNNData()) {
     CHECK(!IsView());
+    MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_->GetMem());
+    return ptr_->mkl_mem_->GetRaw();
+  }
   ptr_->SetMKLMem(IsView() ? ptr_->storage_shape : shape_, dtype_);
   MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_->GetMem());
   if (IsView()) {

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 08/17: Unit tests on GetMKLDNNDataReorder.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 7d6e8e0b3adb4ff039a7585e01b19f88498a9f89
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sat Apr 21 09:38:47 2018 +0000

    Unit tests on GetMKLDNNDataReorder.
---
 tests/cpp/operator/mkldnn.cc | 142 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 115 insertions(+), 27 deletions(-)

diff --git a/tests/cpp/operator/mkldnn.cc b/tests/cpp/operator/mkldnn.cc
index c4515f1..26faeed 100644
--- a/tests/cpp/operator/mkldnn.cc
+++ b/tests/cpp/operator/mkldnn.cc
@@ -87,22 +87,44 @@ TEST(MKLDNN_UTIL_FUNC, MemFormat) {
   CHECK_EQ(mkldnn_oihw, 12);
 }
 
-static void InitArray(NDArray &arr) {
-  const TBlob &blob = arr.data();
+static void InitArray(NDArray *arr) {
+  const TBlob &blob = arr->data();
   mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>();
   size_t size = blob.Size();
   for (size_t i = 0; i < size; i++)
     data[i] = i;
 }
 
+static void VerifyDefMem(const mkldnn::memory &mem) {
+  mkldnn::memory::primitive_desc pd = mem.get_primitive_desc();
+  mshadow::default_real_t *data
+      = static_cast<mshadow::default_real_t *>(mem.get_data_handle());
+  size_t size = pd.get_size() / sizeof(mshadow::default_real_t);
+  size_t num_same = 0;
+  for (size_t i = 0; i < size; i++)
+    num_same += data[i] == static_cast<mshadow::default_real_t>(i);
+  EXPECT_EQ(num_same, size);
+}
+
 static void VerifyMem(const mkldnn::memory &mem) {
   mkldnn::memory::primitive_desc pd = mem.get_primitive_desc();
+
   if (pd.desc().data.format == GetDefaultFormat(pd.desc())) {
-    mshadow::default_real_t *data
-        = static_cast<mshadow::default_real_t *>(mem.get_data_handle());
-    size_t size = pd.get_size() / sizeof(mshadow::default_real_t);
-    for (size_t i = 0; i < size; i++)
-      CHECK_EQ(data[i], static_cast<mshadow::default_real_t>(i));
+    VerifyDefMem(mem);
+  } else {
+    mkldnn::memory::dims dims(pd.desc().data.ndims);
+    for (size_t i = 0; i < dims.size(); i++)
+      dims[i] = pd.desc().data.dims[i];
+    mkldnn::memory::desc desc{dims,
+                              static_cast<mkldnn::memory::data_type>(pd.desc().data.data_type),
+                              static_cast<mkldnn::memory::format>(GetDefaultFormat(pd.desc()))};
+    mkldnn::memory::primitive_desc new_pd(desc, CpuEngine::Get()->get_engine());
+    mkldnn::memory new_mem(new_pd);
+
+    std::vector<mkldnn::primitive> net;
+    net.push_back(mkldnn::reorder(mem, new_mem));
+    mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
+    VerifyDefMem(new_mem);
   }
 }
 
@@ -115,57 +137,123 @@ static mkldnn::memory::primitive_desc GetMemPD(const TShape s, int dtype,
   return mkldnn::memory::primitive_desc(desc, CpuEngine::Get()->get_engine());
 }
 
+static std::vector<mkldnn::memory::format> GetMKLDNNFormat(size_t num_dims, int dtype) {
+  if (num_dims == 4) {
+    mkldnn::memory::dims data_dims{1, 3, 224, 224};
+    mkldnn::memory::desc data_md{data_dims, get_mkldnn_type(dtype),
+                                 mkldnn::memory::format::any};
+    mkldnn::memory::dims weight_dims{96, 3, 11, 11};
+    mkldnn::memory::desc weight_md{weight_dims, get_mkldnn_type(dtype),
+                                   mkldnn::memory::format::any};
+    mkldnn::memory::dims output_dims{1, 96, 54, 54};
+    mkldnn::memory::desc out_md{output_dims, get_mkldnn_type(dtype),
+                                mkldnn::memory::format::any};
+    mkldnn::memory::dims strides{4, 4};
+    mkldnn::memory::dims padding{0, 0};
+
+    mkldnn::convolution_forward::desc desc(mkldnn::prop_kind::forward_training,
+                                           mkldnn::algorithm::convolution_direct,
+                                           data_md, weight_md, out_md, strides,
+                                           padding, padding, mkldnn::padding_kind::zero);
+    mkldnn::convolution_forward::primitive_desc pd(desc, CpuEngine::Get()->get_engine());
+    std::vector<mkldnn::memory::format> ret(2);
+    ret[0] = static_cast<mkldnn::memory::format>(pd.dst_primitive_desc().desc().data.format);
+    ret[1] = static_cast<mkldnn::memory::format>(pd.weights_primitive_desc().desc().data.format);
+    printf("format: %d, %d\n", ret[0], ret[1]);
+    return ret;
+  } else if (num_dims == 5) {
+    mkldnn::memory::dims data_dims{1, 32, 112, 112};
+    mkldnn::memory::desc data_md{data_dims, get_mkldnn_type(dtype),
+                                 mkldnn::memory::format::any};
+    mkldnn::memory::dims weight_dims{32, 1, 1, 3, 3};
+    mkldnn::memory::desc weight_md{weight_dims, get_mkldnn_type(dtype),
+                                   mkldnn::memory::format::any};
+    mkldnn::memory::dims output_dims{1, 32, 112, 112};
+    mkldnn::memory::desc out_md{output_dims, get_mkldnn_type(dtype),
+                                mkldnn::memory::format::any};
+    mkldnn::memory::dims strides{1, 1};
+    mkldnn::memory::dims padding{1, 1};
+
+    mkldnn::convolution_forward::desc desc(mkldnn::prop_kind::forward_training,
+                                           mkldnn::algorithm::convolution_direct,
+                                           data_md, weight_md, out_md, strides,
+                                           padding, padding, mkldnn::padding_kind::zero);
+    mkldnn::convolution_forward::primitive_desc pd(desc, CpuEngine::Get()->get_engine());
+    std::vector<mkldnn::memory::format> ret(1);
+    ret[0] = static_cast<mkldnn::memory::format>(pd.weights_primitive_desc().desc().data.format);
+    printf("format: %d\n", ret[0]);
+    return ret;
+  } else {
+    return std::vector<mkldnn::memory::format>();
+  }
+}
+
 TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
+  printf("test get_data_reorder\n");
   std::vector<TShape> shapes;
   std::vector<mkldnn::memory::primitive_desc> pds;
   int dtype = mshadow::DataType<mshadow::default_real_t>::kFlag;
   {
     // 1D
     TShape s(1);
-    s[0] = 100;
+    s[0] = 279936;
     shapes.push_back(s);
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::x));
   }
   {
     // 2D
     TShape s(2);
-    s[0] = 25;
-    s[1] = 4;
+    s[0] = 96;
+    s[1] = 2916;
     shapes.push_back(s);
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nc));
-    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::io));
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::oi));
   }
   {
     // 4D
-    TShape s(4);
-    s[0] = 5;
-    s[1] = 5;
-    s[2] = 2;
-    s[3] = 2;
-    shapes.push_back(s);
-    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nchw));
-    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::oihw));
+    TShape s1(4);
+    s1[0] = 1; s1[1] = 96; s1[2] = 54; s1[3] = 54;
+    shapes.push_back(s1);
+    pds.push_back(GetMemPD(s1, dtype, mkldnn::memory::format::nchw));
+
+    TShape s2(4);
+    s2[0] = 96; s2[1] = 3; s2[2] = 11; s2[3] = 11;
+    shapes.push_back(s2);
+    pds.push_back(GetMemPD(s2, dtype, mkldnn::memory::format::oihw));
+
+    std::vector<mkldnn::memory::format> formats = GetMKLDNNFormat(4, dtype);
+    pds.push_back(GetMemPD(s1, dtype, formats[0]));
+    pds.push_back(GetMemPD(s2, dtype, formats[1]));
   }
   {
     // 5D
     TShape s(5);
-    s[0] = 5;
-    s[1] = 5;
-    s[2] = 2;
-    s[3] = 2;
-    s[4] = 1;
+    s[0] = 96; s[1] = 1; s[2] = 3; s[3] = 11; s[4] = 11;
     shapes.push_back(s);
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::goihw));
+
+    std::vector<mkldnn::memory::format> formats = GetMKLDNNFormat(5, dtype);
+    pds.push_back(GetMemPD(s, dtype, formats[0]));
   }
 
   // Reorder from the default to any other layout.
   for (auto s : shapes) {
     NDArray arr(s, Context());
-    InitArray(arr);
+    InitArray(&arr);
     for (auto pd : pds) {
-      const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(pd);
-      VerifyMem(*mem);
+      if (s.Size() == pd.get_size() / sizeof(mshadow::default_real_t)) {
+        const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(pd);
+        printf("reorder from (");
+        for (size_t i = 0; i < s.ndim(); i++)
+          printf("%ld, ", s[i]);
+        printf(") to (");
+        for (int i = 0; i < pd.desc().data.ndims; i++)
+          printf("%d, ", pd.desc().data.dims[i]);
+        printf("), format: %d\n", pd.desc().data.format);
+        MKLDNNStream::Get()->Submit(false);
+        VerifyMem(*mem);
+        MKLDNNStream::Get()->Cleanup();
+      }
     }
   }
 

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 14/17: Fix jenkins.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 608583158557a40668705a5c090dd0f9fe7a89e8
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Mon Apr 23 06:36:16 2018 +0000

    Fix jenkins.
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index cc04808..cf23f43 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -568,7 +568,7 @@ try {
         ws('workspace/ut-cpp-gpu') {
           timeout(time: max_time, unit: 'MINUTES') {
             init_git()
-            unpack_lib('cmake_mkldnn_gpu', mx_cmake_lib)
+            unpack_lib('cmake_mkldnn_gpu', mx_cmake_mkldnn_lib)
             sh "ci/build.py --nvidiadocker --platform ubuntu_gpu /work/runtime_functions.sh unittest_ubuntu_gpu_cpp"
           }
         }

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 16/17: test jenkins.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 652a8953c44585f831f4e220c8ae82d402be1576
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Thu Apr 26 23:23:20 2018 +0000

    test jenkins.
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 373210e..20d1266 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -26,7 +26,7 @@ mx_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdpart
 mx_dist_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a, 3rdparty/ps-lite/build/libps.a, deps/lib/libprotobuf-lite.a, deps/lib/libzmq.a'
 // mxnet cmake libraries, in cmake builds we do not produce a libnvvm static library by default.
 mx_cmake_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so'
-mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/3rdparty/mkldnn/src/libmkldnn.so.0'
+mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/3rdparty/mkldnn/src/libmkldnn.so.0, build/3rdparty/mkldnn/Doxyfile'
 mx_mkldnn_lib = 'lib/libmxnet.so, lib/libmxnet.a, lib/libiomp5.so, lib/libmkldnn.so.0, lib/libmklml_intel.so, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a'
 // command to start a docker container
 docker_run = 'tests/ci_build/ci_build.sh'

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 17/17: test Jenkins.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 1d33fc798231f27d8f7c19e517955d91890faf3a
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Fri Apr 27 00:03:31 2018 +0000

    test Jenkins.
---
 Jenkinsfile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 20d1266..1402e8e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -26,7 +26,7 @@ mx_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdpart
 mx_dist_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a, 3rdparty/ps-lite/build/libps.a, deps/lib/libprotobuf-lite.a, deps/lib/libzmq.a'
 // mxnet cmake libraries, in cmake builds we do not produce a libnvvm static library by default.
 mx_cmake_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so'
-mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/3rdparty/mkldnn/src/libmkldnn.so.0, build/3rdparty/mkldnn/Doxyfile'
+mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/libmkldnn.so.0'
 mx_mkldnn_lib = 'lib/libmxnet.so, lib/libmxnet.a, lib/libiomp5.so, lib/libmkldnn.so.0, lib/libmklml_intel.so, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a'
 // command to start a docker container
 docker_run = 'tests/ci_build/ci_build.sh'
@@ -288,6 +288,7 @@ try {
           timeout(time: max_time, unit: 'MINUTES') {
             init_git()
             sh "ci/build.py --platform ubuntu_gpu /work/runtime_functions.sh build_ubuntu_gpu_cmake_mkldnn" //build_cuda
+            sh "cp build/3rdparty/mkldnn/src/libmkldnn.so.0 build/"
             pack_lib('cmake_mkldnn_gpu', mx_cmake_mkldnn_lib)
           }
         }

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 09/17: Fix lint error.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 9d1b9dc89f9a59b8ca3ee982786f64210a697085
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sat Apr 21 09:43:55 2018 +0000

    Fix lint error.
---
 src/operator/nn/mkldnn/mkldnn_base-inl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/operator/nn/mkldnn/mkldnn_base-inl.h b/src/operator/nn/mkldnn/mkldnn_base-inl.h
index e94c3df..f47a051 100644
--- a/src/operator/nn/mkldnn/mkldnn_base-inl.h
+++ b/src/operator/nn/mkldnn/mkldnn_base-inl.h
@@ -286,7 +286,7 @@ class MKLDNNStream {
     return !net.empty();
   }
 
-  void Submit(bool cleanup=true) {
+  void Submit(bool cleanup = true) {
     if (!net.empty()) {
       mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
       net.clear();

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 10/17: Add more test cases.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 2bd669172526307a94943daf8f4d409962e44c64
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sun Apr 22 04:35:50 2018 +0000

    Add more test cases.
---
 tests/cpp/operator/mkldnn.cc | 59 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 50 insertions(+), 9 deletions(-)

diff --git a/tests/cpp/operator/mkldnn.cc b/tests/cpp/operator/mkldnn.cc
index 26faeed..661f3c5 100644
--- a/tests/cpp/operator/mkldnn.cc
+++ b/tests/cpp/operator/mkldnn.cc
@@ -95,6 +95,16 @@ static void InitArray(NDArray *arr) {
     data[i] = i;
 }
 
+static void InitMKLDNNArray(NDArray *arr, const mkldnn::memory::primitive_desc &pd) {
+  const TBlob &blob = arr->data();
+  mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>();
+  size_t size = blob.Size();
+  for (size_t i = 0; i < size; i++)
+    data[i] = i;
+  arr->MKLDNNDataReorderAsync(pd);
+  arr->WaitToRead();
+}
+
 static void VerifyDefMem(const mkldnn::memory &mem) {
   mkldnn::memory::primitive_desc pd = mem.get_primitive_desc();
   mshadow::default_real_t *data
@@ -199,6 +209,9 @@ TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
     s[0] = 279936;
     shapes.push_back(s);
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::x));
+    s[0] = 34848;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::x));
   }
   {
     // 2D
@@ -207,7 +220,10 @@ TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
     s[1] = 2916;
     shapes.push_back(s);
     pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nc));
-    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::oi));
+    s[0] = 96;
+    s[1] = 363;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nc));
   }
   {
     // 4D
@@ -258,14 +274,39 @@ TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
   }
 
   // Reorder from a special layout to another layout.
-//  for (auto s : shapes) {
-//    NDArray arr(s, Context());
-//    InitMKLDNNArray(arr);
-//    for (auto pd : pds) {
-//      const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(pd);
-//      VerifyMem(*mem);
-//    }
-//  }
+  for (auto s : shapes) {
+    for (auto from_pd : pds) {
+      if (from_pd.get_size() / sizeof(mshadow::default_real_t) == s.Size()) {
+        NDArray arr(s, Context());
+        // There is possibility that the dimensions of an NDArray doesn't match
+        // with the MKLDNN memory inside.
+        printf("Init array (");
+        for (size_t i = 0; i < s.ndim(); i++)
+          printf("%ld, ", s[i]);
+        printf(") with MKLDNN memory (");
+        for (int i = 0; i < from_pd.desc().data.ndims; i++)
+          printf("%d, ", from_pd.desc().data.dims[i]);
+        printf("), format: %d\n", from_pd.desc().data.format);
+        InitMKLDNNArray(&arr, from_pd);
+        for (auto to_pd : pds) {
+          if (to_pd.get_size() / sizeof(mshadow::default_real_t) == s.Size()) {
+            const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(to_pd);
+            printf("reorder from (");
+            for (size_t i = 0; i < s.ndim(); i++)
+              printf("%ld, ", s[i]);
+            printf("), format: %d to (",
+                   arr.GetMKLDNNData()->get_primitive_desc().desc().data.format);
+            for (int i = 0; i < to_pd.desc().data.ndims; i++)
+              printf("%d, ", to_pd.desc().data.dims[i]);
+            printf("), format: %d\n", to_pd.desc().data.format);
+            MKLDNNStream::Get()->Submit(false);
+            VerifyMem(*mem);
+            MKLDNNStream::Get()->Cleanup();
+          }
+        }
+      }
+    }
+  }
 }
 
 #endif

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 06/17: Add C++ unit test for NDArray.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 29cd215d29594583733cf50c19957775278f13df
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sat Apr 21 06:51:51 2018 +0000

    Add C++ unit test for NDArray.
---
 tests/cpp/operator/mkldnn.cc | 96 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 96 insertions(+)

diff --git a/tests/cpp/operator/mkldnn.cc b/tests/cpp/operator/mkldnn.cc
index 9d4b982..c4515f1 100644
--- a/tests/cpp/operator/mkldnn.cc
+++ b/tests/cpp/operator/mkldnn.cc
@@ -28,6 +28,8 @@
 #include "gtest/gtest.h"
 #include "../../src/operator/nn/mkldnn/mkldnn_base-inl.h"
 
+using namespace mxnet;
+
 #if __GNUC__ >= 5
 bool test_mem_align(void *mem, size_t size, size_t alignment, size_t space) {
   void *ret1, *ret2;
@@ -84,4 +86,98 @@ TEST(MKLDNN_UTIL_FUNC, MemFormat) {
   CHECK_EQ(mkldnn_nchw, 5);
   CHECK_EQ(mkldnn_oihw, 12);
 }
+
+static void InitArray(NDArray &arr) {
+  const TBlob &blob = arr.data();
+  mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>();
+  size_t size = blob.Size();
+  for (size_t i = 0; i < size; i++)
+    data[i] = i;
+}
+
+static void VerifyMem(const mkldnn::memory &mem) {
+  mkldnn::memory::primitive_desc pd = mem.get_primitive_desc();
+  if (pd.desc().data.format == GetDefaultFormat(pd.desc())) {
+    mshadow::default_real_t *data
+        = static_cast<mshadow::default_real_t *>(mem.get_data_handle());
+    size_t size = pd.get_size() / sizeof(mshadow::default_real_t);
+    for (size_t i = 0; i < size; i++)
+      CHECK_EQ(data[i], static_cast<mshadow::default_real_t>(i));
+  }
+}
+
+static mkldnn::memory::primitive_desc GetMemPD(const TShape s, int dtype,
+                                               mkldnn::memory::format format) {
+  mkldnn::memory::dims dims(s.ndim());
+  for (size_t i = 0; i < dims.size(); i++)
+    dims[i] = s[i];
+  mkldnn::memory::desc desc{dims, get_mkldnn_type(dtype), format};
+  return mkldnn::memory::primitive_desc(desc, CpuEngine::Get()->get_engine());
+}
+
+TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
+  std::vector<TShape> shapes;
+  std::vector<mkldnn::memory::primitive_desc> pds;
+  int dtype = mshadow::DataType<mshadow::default_real_t>::kFlag;
+  {
+    // 1D
+    TShape s(1);
+    s[0] = 100;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::x));
+  }
+  {
+    // 2D
+    TShape s(2);
+    s[0] = 25;
+    s[1] = 4;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nc));
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::io));
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::oi));
+  }
+  {
+    // 4D
+    TShape s(4);
+    s[0] = 5;
+    s[1] = 5;
+    s[2] = 2;
+    s[3] = 2;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::nchw));
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::oihw));
+  }
+  {
+    // 5D
+    TShape s(5);
+    s[0] = 5;
+    s[1] = 5;
+    s[2] = 2;
+    s[3] = 2;
+    s[4] = 1;
+    shapes.push_back(s);
+    pds.push_back(GetMemPD(s, dtype, mkldnn::memory::format::goihw));
+  }
+
+  // Reorder from the default to any other layout.
+  for (auto s : shapes) {
+    NDArray arr(s, Context());
+    InitArray(arr);
+    for (auto pd : pds) {
+      const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(pd);
+      VerifyMem(*mem);
+    }
+  }
+
+  // Reorder from a special layout to another layout.
+//  for (auto s : shapes) {
+//    NDArray arr(s, Context());
+//    InitMKLDNNArray(arr);
+//    for (auto pd : pds) {
+//      const mkldnn::memory *mem = arr.GetMKLDNNDataReorder(pd);
+//      VerifyMem(*mem);
+//    }
+//  }
+}
+
 #endif

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 03/17: Update comments.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit d62f138d7fc27f775befa7c61072caff0ceac718
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Fri Apr 20 04:10:49 2018 +0000

    Update comments.
---
 src/ndarray/ndarray.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/ndarray/ndarray.cc b/src/ndarray/ndarray.cc
index 533d2be..8f4fb47 100644
--- a/src/ndarray/ndarray.cc
+++ b/src/ndarray/ndarray.cc
@@ -566,11 +566,13 @@ void NDArray::MKLDNNDataReorderAsync(const mkldnn::memory::primitive_desc &desc)
 
 const mkldnn::memory *NDArray::GetMKLDNNData() const {
   CHECK(storage_type() == kDefaultStorage);
-  // If this array uses MKLDNN layout, we have to make sure it's not a view.
-  // Otherwise, we'll have to change the layout inside the array.
   if (IsMKLDNNData()) {
+    // If this array uses MKLDNN layout, we have to make sure it's not a view.
+    // Otherwise, we'll have to change the layout inside the array.
     CHECK(!IsView());
     MKLDNNStream::Get()->RegisterMem(ptr_->mkl_mem_->GetMem());
+    // If this array uses MKLDNN format, we should return now. Otherwise,
+    // SetMKLMem may mess up mkl_mem_.
     return ptr_->mkl_mem_->GetRaw();
   }
   ptr_->SetMKLMem(IsView() ? ptr_->storage_shape : shape_, dtype_);

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 12/17: Reorganize test code.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 9e90090f0b64906d191d1e3fa99802c8be2ba5cf
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sun Apr 22 04:46:07 2018 +0000

    Reorganize test code.
---
 tests/cpp/operator/mkldnn.cc | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tests/cpp/operator/mkldnn.cc b/tests/cpp/operator/mkldnn.cc
index e59e767..58ad894 100644
--- a/tests/cpp/operator/mkldnn.cc
+++ b/tests/cpp/operator/mkldnn.cc
@@ -205,10 +205,15 @@ static std::vector<mkldnn::memory::format> GetMKLDNNFormat(size_t num_dims, int
   }
 }
 
-TEST(MKLDNN_NDArray, GetDataReorder) {
+struct TestArrayShapes {
   std::vector<TShape> shapes;
   std::vector<mkldnn::memory::primitive_desc> pds;
+};
+
+static TestArrayShapes GetTestArrayShapes() {
   int dtype = mshadow::DataType<mshadow::default_real_t>::kFlag;
+  std::vector<TShape> shapes;
+  std::vector<mkldnn::memory::primitive_desc> pds;
   {
     // 1D
     TShape s(1);
@@ -258,6 +263,18 @@ TEST(MKLDNN_NDArray, GetDataReorder) {
     pds.push_back(GetMemPD(s, dtype, formats[0]));
   }
 
+  TestArrayShapes ret;
+  ret.shapes = shapes;
+  ret.pds = pds;
+  return ret;
+}
+
+TEST(MKLDNN_NDArray, GetDataReorder) {
+  TestArrayShapes tas = GetTestArrayShapes();
+  std::vector<TShape> shapes = tas.shapes;
+  std::vector<mkldnn::memory::primitive_desc> pds = tas.pds;
+
+
   // Reorder from the default to any other layout.
   for (auto s : shapes) {
     NDArray arr(s, Context());

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 11/17: add comments for the test code.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 99bd17f917a8e1ba533567a543ed8f5bd147e60f
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sun Apr 22 04:41:00 2018 +0000

    add comments for the test code.
---
 tests/cpp/operator/mkldnn.cc | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/cpp/operator/mkldnn.cc b/tests/cpp/operator/mkldnn.cc
index 661f3c5..e59e767 100644
--- a/tests/cpp/operator/mkldnn.cc
+++ b/tests/cpp/operator/mkldnn.cc
@@ -87,6 +87,7 @@ TEST(MKLDNN_UTIL_FUNC, MemFormat) {
   CHECK_EQ(mkldnn_oihw, 12);
 }
 
+// Init arrays with the default layout.
 static void InitArray(NDArray *arr) {
   const TBlob &blob = arr->data();
   mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>();
@@ -95,6 +96,7 @@ static void InitArray(NDArray *arr) {
     data[i] = i;
 }
 
+// Init arrays with the specified layout.
 static void InitMKLDNNArray(NDArray *arr, const mkldnn::memory::primitive_desc &pd) {
   const TBlob &blob = arr->data();
   mshadow::default_real_t *data = blob.dptr<mshadow::default_real_t>();
@@ -147,6 +149,11 @@ static mkldnn::memory::primitive_desc GetMemPD(const TShape s, int dtype,
   return mkldnn::memory::primitive_desc(desc, CpuEngine::Get()->get_engine());
 }
 
+// This function gets special MKLDNN formats without knowing the specific
+// hardware configuration. Certainly, it potentially misses some format if
+// it's specific for certain array shapes. It covers at least one special format
+// for each of the formats: nchw, oihw, goihw.
+// To test the logic of the code in NDArray, these formats should be enough.
 static std::vector<mkldnn::memory::format> GetMKLDNNFormat(size_t num_dims, int dtype) {
   if (num_dims == 4) {
     mkldnn::memory::dims data_dims{1, 3, 224, 224};
@@ -198,8 +205,7 @@ static std::vector<mkldnn::memory::format> GetMKLDNNFormat(size_t num_dims, int
   }
 }
 
-TEST(MKLDNN_GET_DATA_REORDER, DataReorder) {
-  printf("test get_data_reorder\n");
+TEST(MKLDNN_NDArray, GetDataReorder) {
   std::vector<TShape> shapes;
   std::vector<mkldnn::memory::primitive_desc> pds;
   int dtype = mshadow::DataType<mshadow::default_real_t>::kFlag;

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 04/17: Handle all cases for GetMKLDNNDataReorder

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit a1cb6a6c152731067622aff101a8b66b383698ec
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Fri Apr 20 22:17:15 2018 +0000

    Handle all cases for GetMKLDNNDataReorder
---
 src/ndarray/ndarray.cc                   | 37 +++++++++++++++++++++++---------
 src/operator/nn/mkldnn/mkldnn_base-inl.h | 10 +++++++++
 2 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/src/ndarray/ndarray.cc b/src/ndarray/ndarray.cc
index 8f4fb47..82de094 100644
--- a/src/ndarray/ndarray.cc
+++ b/src/ndarray/ndarray.cc
@@ -485,8 +485,8 @@ const mkldnn::memory *NDArray::GetMKLDNNData(
 }
 
 const mkldnn::memory *NDArray::GetMKLDNNDataReorder(
-    const mkldnn::memory::primitive_desc &desc) const {
-  if (desc.get_size() != shape().Size() * GetTypeSize(dtype_)) {
+    const mkldnn::memory::primitive_desc &new_pd) const {
+  if (new_pd.get_size() != shape().Size() * GetTypeSize(dtype_)) {
     LOG(FATAL) << "The size of NDArray doesn't match the requested MKLDNN memory desc";
     return nullptr;
   }
@@ -495,24 +495,41 @@ const mkldnn::memory *NDArray::GetMKLDNNDataReorder(
   const mkldnn::memory *mem = GetMKLDNNData();
   // If the memory descriptor matches, it's easy.
   MKLDNNStream *stream = MKLDNNStream::Get();
-  if (mem->get_primitive_desc() == desc) {
-    return GetMKLDNNExact(mem, desc);
+  if (mem->get_primitive_desc() == new_pd) {
+    return GetMKLDNNExact(mem, new_pd);
   }
 
-  mkldnn::memory::primitive_desc _desc = desc;
+  mkldnn::memory::primitive_desc _pd = new_pd;
+  mkldnn::memory::desc desc1 = mem->get_primitive_desc().desc();
+  mkldnn::memory::desc desc2 = _pd.desc();
   // Now we need to determine if we should reorder the memory.
   // If both use the default formats, we think we don't need to reorder.
-  mkldnn::memory::desc desc1 = mem->get_primitive_desc().desc();
-  mkldnn::memory::desc desc2 = _desc.desc();
   if (desc1.data.format == GetDefaultFormat(desc1) &&
       desc2.data.format == GetDefaultFormat(desc2)) {
-    mkldnn_mem_ptr ret(new mkldnn::memory(desc, mem->get_data_handle()));
+    mkldnn_mem_ptr ret(new mkldnn::memory(new_pd, mem->get_data_handle()));
     stream->RegisterMem(ret);
     return ret.get();
-  } else {
-    mkldnn::memory *ret = TmpMemMgr::Get()->Alloc(desc);
+  } else if (same_shape(desc1, desc2)) {
+    // If they have the same shape, we can reorder data directly.
+    mkldnn::memory *ret = TmpMemMgr::Get()->Alloc(new_pd);
     stream->RegisterPrim(mkldnn::reorder(*mem, *ret));
     return ret;
+  } else {
+    // If they have different shapes, we need to reshape the array first.
+    // Since this method will only be used inside an operator, we can call
+    // MKLDNNDataReshape to reshape an array.
+    TShape required_shape(desc2.data.ndims);
+    for (int i = 0; i < desc2.data.ndims; i++)
+      required_shape[i] = desc2.data.dims[i];
+    NDArray reshaped = MKLDNNDataReshape(required_shape);
+    const mkldnn::memory *ret = reshaped.GetMKLDNNData();
+    if (ret->get_primitive_desc() == new_pd) {
+      return GetMKLDNNExact(ret, new_pd);
+    } else {
+      mkldnn::memory *ret2 = TmpMemMgr::Get()->Alloc(new_pd);
+      stream->RegisterPrim(mkldnn::reorder(*ret, *ret2));
+      return ret2;
+    }
   }
 }
 
diff --git a/src/operator/nn/mkldnn/mkldnn_base-inl.h b/src/operator/nn/mkldnn/mkldnn_base-inl.h
index 489351e..4ad8f05 100644
--- a/src/operator/nn/mkldnn/mkldnn_base-inl.h
+++ b/src/operator/nn/mkldnn/mkldnn_base-inl.h
@@ -348,6 +348,16 @@ inline bool same_shape(const TShape &shape, const mkldnn_dims_t dims, int ndims)
   return true;
 }
 
+inline bool same_shape(const mkldnn::memory::desc &desc1,
+                       const mkldnn::memory::desc &desc2) {
+  if (desc1.data.ndims != desc2.data.ndims)
+    return false;
+  for (int i = 0; i < desc1.data.ndims; i++)
+    if (desc1.data.dims[i] != desc2.data.dims[i])
+      return false;
+  return true;
+}
+
 inline bool same_shape(const TShape &shape, int dtype,
                        const mkldnn::memory::desc &desc) {
   return same_shape(shape, desc.data.dims, desc.data.ndims)

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 15/17: Fix Jenkins.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit e5549995b9bac8194826503985b4e3292d271cc8
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Thu Apr 26 20:55:43 2018 +0000

    Fix Jenkins.
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index cf23f43..373210e 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -26,7 +26,7 @@ mx_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdpart
 mx_dist_lib = 'lib/libmxnet.so, lib/libmxnet.a, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a, 3rdparty/ps-lite/build/libps.a, deps/lib/libprotobuf-lite.a, deps/lib/libzmq.a'
 // mxnet cmake libraries, in cmake builds we do not produce a libnvvm static library by default.
 mx_cmake_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so'
-mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/3rdparty/mkldnn/src/libmkldnn.so, build/3rdparty/mkldnn/src/libmkldnn.so.0'
+mx_cmake_mkldnn_lib = 'build/libmxnet.so, build/libmxnet.a, build/3rdparty/dmlc-core/libdmlc.a, build/tests/mxnet_unit_tests, build/3rdparty/openmp/runtime/src/libomp.so, build/3rdparty/mkldnn/src/libmkldnn.so.0'
 mx_mkldnn_lib = 'lib/libmxnet.so, lib/libmxnet.a, lib/libiomp5.so, lib/libmkldnn.so.0, lib/libmklml_intel.so, 3rdparty/dmlc-core/libdmlc.a, 3rdparty/nnvm/lib/libnnvm.a'
 // command to start a docker container
 docker_run = 'tests/ci_build/ci_build.sh'

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 07/17: Fix a minor bug.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit deeeea42e4c1590b3ca16b028056295116c6ae9e
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Sat Apr 21 09:37:04 2018 +0000

    Fix a minor bug.
---
 src/operator/nn/mkldnn/mkldnn_base-inl.h | 21 +++++++++++++--------
 src/operator/nn/mkldnn/mkldnn_base.cc    |  5 +++++
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/operator/nn/mkldnn/mkldnn_base-inl.h b/src/operator/nn/mkldnn/mkldnn_base-inl.h
index 4ad8f05..e94c3df 100644
--- a/src/operator/nn/mkldnn/mkldnn_base-inl.h
+++ b/src/operator/nn/mkldnn/mkldnn_base-inl.h
@@ -272,12 +272,11 @@ class MKLDNNStream {
   std::vector<std::shared_ptr<const mkldnn::memory> > mem_holder;
 
  public:
-  static MKLDNNStream *Get() {
-    static thread_local MKLDNNStream stream;
-    return &stream;
-  }
+  static MKLDNNStream *Get();
 
-  void RegisterPrim(const mkldnn::primitive &prim) { net.push_back(prim); }
+  void RegisterPrim(const mkldnn::primitive &prim) {
+    net.push_back(prim);
+  }
 
   void RegisterMem(std::shared_ptr<const mkldnn::memory> mem) {
     mem_holder.push_back(mem);
@@ -287,10 +286,16 @@ class MKLDNNStream {
     return !net.empty();
   }
 
-  void Submit() {
-    if (!net.empty())
+  void Submit(bool cleanup=true) {
+    if (!net.empty()) {
       mkldnn::stream(mkldnn::stream::kind::eager).submit(net).wait();
-    net.clear();
+      net.clear();
+    }
+    if (cleanup)
+      Cleanup();
+  }
+
+  void Cleanup() {
     mem_holder.clear();
     TmpMemMgr::Get()->Reset();
   }
diff --git a/src/operator/nn/mkldnn/mkldnn_base.cc b/src/operator/nn/mkldnn/mkldnn_base.cc
index 4fed143..c0e1ee6 100644
--- a/src/operator/nn/mkldnn/mkldnn_base.cc
+++ b/src/operator/nn/mkldnn/mkldnn_base.cc
@@ -25,6 +25,11 @@
 
 namespace mxnet {
 
+MKLDNNStream *MKLDNNStream::Get() {
+  static thread_local MKLDNNStream stream;
+  return &stream;
+}
+
 void *AlignMem(void *mem, size_t size, size_t alignment, size_t *space) {
   if (size > *space)
     return nullptr;

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.

[incubator-mxnet] 05/17: avoid unnecessary message.

Posted by jx...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 3713ead5133d076ebfcd76413d965999cd380e08
Author: Da Zheng <zh...@gmail.com>
AuthorDate: Fri Apr 20 22:49:38 2018 +0000

    avoid unnecessary message.
---
 src/operator/nn/mkldnn/mkldnn_base.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/operator/nn/mkldnn/mkldnn_base.cc b/src/operator/nn/mkldnn/mkldnn_base.cc
index df37db5..4fed143 100644
--- a/src/operator/nn/mkldnn/mkldnn_base.cc
+++ b/src/operator/nn/mkldnn/mkldnn_base.cc
@@ -57,8 +57,11 @@ mkldnn::memory *TmpMemMgr::Alloc(const mkldnn::memory::primitive_desc &pd) {
     this->curr_mem = static_cast<char *>(mem) + pd.get_size();
     return ret.get();
   } else {
-    LOG(WARNING) << "Allocate " << pd.get_size()
-        << " bytes with malloc directly";
+    // If curr_mem has been initialized and we still reach here. It means
+    // the current allocated memory isn't enough.
+    if (this->curr_mem)
+      LOG(WARNING) << "Allocate " << pd.get_size()
+          << " bytes with malloc directly";
     mkldnn_mem_ptr ret(new mkldnn::memory(pd));
     MKLDNNStream::Get()->RegisterMem(ret);
     return ret.get();

-- 
To stop receiving notification emails like this one, please contact
jxie@apache.org.