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 2017/08/24 17:06:04 UTC

[incubator-mxnet] branch master updated: fix for amalgamation build with MIN=1 (#7597)

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


The following commit(s) were added to refs/heads/master by this push:
     new d839abc  fix for amalgamation build with MIN=1 (#7597)
d839abc is described below

commit d839abc09ce656205028e9f3df06067d87a2fc6c
Author: moin <as...@yahoo.de>
AuthorDate: Thu Aug 24 19:06:01 2017 +0200

    fix for amalgamation build with MIN=1 (#7597)
---
 amalgamation/amalgamation.py       |  4 ++++
 src/operator/fully_connected-inl.h | 23 +++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/amalgamation/amalgamation.py b/amalgamation/amalgamation.py
index 22b421d..2aba8f4 100644
--- a/amalgamation/amalgamation.py
+++ b/amalgamation/amalgamation.py
@@ -32,6 +32,10 @@ blacklist = [
 minimum = int(sys.argv[6]) if len(sys.argv) > 5 else 0
 android = int(sys.argv[7]) if len(sys.argv) > 6 else 0
 
+# blacklist linear algebra headers when building without blas.
+if minimum != 0:
+    blacklist.append('linalg.h')
+
 def pprint(lst):
     for item in lst:
         print item
diff --git a/src/operator/fully_connected-inl.h b/src/operator/fully_connected-inl.h
index 6f0cf54..7120b56 100644
--- a/src/operator/fully_connected-inl.h
+++ b/src/operator/fully_connected-inl.h
@@ -33,7 +33,9 @@
 #include <utility>
 #include "./operator_common.h"
 #include "./elemwise_op_common.h"
+#if (MSHADOW_USE_CBLAS != 0)
 #include "linalg.h"
+#endif
 
 namespace mxnet {
 namespace op {
@@ -108,9 +110,12 @@ class FullyConnectedOp : public Operator {
           Shape2(oshape[0], oshape.ProdShape(1, oshape.ndim())), s);
     }
 
-    // Legacy approach shown here for comparison:
-    //   out = dot(data, wmat.T());
+#if (MSHADOW_USE_CBLAS == 0)
+    // Legacy approach for amalgamation build w/out cblas
+    out = dot(data, wmat.T());
+#else
     linalg_gemm(data, wmat, out, false, true, s);
+#endif
     if (!param_.no_bias) {
       Tensor<xpu, 1, DType> bias = in_data[fullc::kBias].get<xpu, 1, DType>(s);
       out += repmat(bias, data.size(0));
@@ -162,18 +167,24 @@ class FullyConnectedOp : public Operator {
     CHECK_NE(req[fullc::kWeight], kWriteInplace) << "cannot write weight inplace";
     // gradient of weight
     Tensor<xpu, 2, DType> gwmat = in_grad[fullc::kWeight].get<xpu, 2, DType>(s);
-    // Legacy approach shown here for comparison:
-    //   Assign(gwmat, req[fullc::kWeight], dot(grad.T(), data));
+#if (MSHADOW_USE_CBLAS == 0)
+    // Legacy approach for amalgamation build w/out cblas
+    Assign(gwmat, req[fullc::kWeight], dot(grad.T(), data));
+#else
     linalg_gemm(grad, data, gwmat, true, false, s, req[fullc::kWeight]);
+#endif
     // gradient of bias
     if (!param_.no_bias) {
       Tensor<xpu, 1, DType> gbias = in_grad[fullc::kBias].get<xpu, 1, DType>(s);
       Assign(gbias, req[fullc::kBias], sum_rows(grad));
     }
     // gradient of data
-    // Legacy approach shown here for comparison:
-    //   Assign(gdata, req[fullc::kData], dot(grad, wmat));
+#if (MSHADOW_USE_CBLAS == 0)
+    // Legacy approach for amalgamation build w/out cblas
+    Assign(gdata, req[fullc::kData], dot(grad, wmat));
+#else
     linalg_gemm(grad, wmat, gdata, false, false, s, req[fullc::kData]);
+#endif
   }
 
  private:

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].