You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by lx...@apache.org on 2017/07/07 15:58:42 UTC

[29/50] [abbrv] incubator-mxnet-test git commit: Add inplace identity (#6896)

Add inplace identity (#6896)

* add inplace identity

* fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/commit/d79e0e0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/tree/d79e0e0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/diff/d79e0e0c

Branch: refs/heads/master
Commit: d79e0e0c1a706daa8dcafdb617e02a76ce7c5288
Parents: 04617df
Author: Eric Junyuan Xie <pi...@users.noreply.github.com>
Authored: Fri Jun 30 20:50:11 2017 -0700
Committer: GitHub <no...@github.com>
Committed: Fri Jun 30 20:50:11 2017 -0700

----------------------------------------------------------------------
 nnvm                                     |  2 +-
 src/operator/tensor/elemwise_unary_op.cc | 34 ++++++++++++++++++++++++++-
 src/operator/tensor/matrix_op.cc         | 18 +++++++++++---
 3 files changed, 49 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/d79e0e0c/nnvm
----------------------------------------------------------------------
diff --git a/nnvm b/nnvm
index d73d6c5..217d3d5 160000
--- a/nnvm
+++ b/nnvm
@@ -1 +1 @@
-Subproject commit d73d6c5b37e7376c1eb30a1ae5c7a42b1fbe22f5
+Subproject commit 217d3d5adefe9b2bd9e3e3fe4fa0695f3a47c93f

http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/d79e0e0c/src/operator/tensor/elemwise_unary_op.cc
----------------------------------------------------------------------
diff --git a/src/operator/tensor/elemwise_unary_op.cc b/src/operator/tensor/elemwise_unary_op.cc
index 4af0877..16591c9 100644
--- a/src/operator/tensor/elemwise_unary_op.cc
+++ b/src/operator/tensor/elemwise_unary_op.cc
@@ -48,6 +48,10 @@ MXNET_OPERATOR_REGISTER_BINARY(_backward_sigmoid)
 MXNET_OPERATOR_REGISTER_UNARY(_copy)
 .MXNET_DESCRIBE("Returns a copy of the input.")
 .add_alias("identity")
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseNone{"_copy"});
 
@@ -59,6 +63,10 @@ NNVM_REGISTER_OP(_backward_copy)
   [](const NodeAttrs& attrs){
     return std::vector<std::pair<int, int> >{{0, 0}};
   })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>);
 
 MXNET_OPERATOR_REGISTER_UNARY(BlockGrad)
@@ -89,6 +97,10 @@ Example::
   [ 1.  1.]
 
 )code" ADD_FILELINE)
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
 .set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes);
 
@@ -100,6 +112,10 @@ MXNET_OPERATOR_REGISTER_UNARY(make_loss)
   [](const NodeAttrs& attrs) {
     return std::vector<std::string>{"loss"};
   })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
 .set_attr<nnvm::FGradient>("FGradient",
   [](const nnvm::NodePtr& n, const std::vector<nnvm::NodeEntry>& ograds) {
@@ -121,6 +137,10 @@ NNVM_REGISTER_OP(_identity_with_attr_like_rhs)
     "FInplaceOption", [](const NodeAttrs& attrs) {
       return std::vector<std::pair<int, int> >{{0, 0}};
     })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+    [](const NodeAttrs& attrs){
+      return std::vector<bool>{true};
+    })
 .set_attr<nnvm::FIgnoreInputs>("FIgnoreInputs",
     [](const NodeAttrs& attrs) { return std::vector<uint32_t>(1, 1); })
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
@@ -160,6 +180,10 @@ Example::
   [](const NodeAttrs& attrs){
     return std::vector<std::pair<int, int> >{{0, 0}};
   })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", CastCompute<cpu>)
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseNone{"_backward_cast"})
 .add_argument("data", "NDArray-or-Symbol", "The input.")
@@ -167,6 +191,14 @@ Example::
 
 NNVM_REGISTER_OP(_backward_cast)
 .set_attr<nnvm::TIsBackward>("TIsBackward", true)
+.set_attr<nnvm::FInplaceOption>("FInplaceOption",
+  [](const NodeAttrs& attrs){
+    return std::vector<std::pair<int, int> >{{0, 0}};
+  })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<FCompute>("FCompute<cpu>", CastCompute<cpu>);
 
 // negative
@@ -262,7 +294,7 @@ Example::
 MXNET_OPERATOR_REGISTER_UNARY(trunc)
 .describe(R"code(Return the element-wise truncated value of the input.
 
-The truncated value of the scalar x is the nearest integer i which is closer to 
+The truncated value of the scalar x is the nearest integer i which is closer to
 zero than x is. In short, the fractional part of the signed number x is discarded.
 
 Example::

http://git-wip-us.apache.org/repos/asf/incubator-mxnet-test/blob/d79e0e0c/src/operator/tensor/matrix_op.cc
----------------------------------------------------------------------
diff --git a/src/operator/tensor/matrix_op.cc b/src/operator/tensor/matrix_op.cc
index f3d6973..6a51d46 100644
--- a/src/operator/tensor/matrix_op.cc
+++ b/src/operator/tensor/matrix_op.cc
@@ -95,7 +95,11 @@ If the argument `reverse` is set to 1, then the special values are inferred from
 .set_attr<nnvm::FInplaceOption>("FInplaceOption",
   [](const NodeAttrs& attrs) {
     return std::vector<std::pair<int, int> >{{0, 0}};
-})
+  })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .add_argument("data", "NDArray-or-Symbol", "Input data to reshape.")
 .add_arguments(ReshapeParam::__FIELDS__());
 
@@ -133,8 +137,12 @@ Example::
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
 .set_attr<nnvm::FInplaceOption>("FInplaceOption",
   [](const NodeAttrs& attrs) {
-  return std::vector<std::pair<int, int> >{{0, 0}};
-})
+    return std::vector<std::pair<int, int> >{{0, 0}};
+  })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .add_argument("data", "NDArray-or-Symbol", "Input array.");
 
 NNVM_REGISTER_OP(transpose)
@@ -211,6 +219,10 @@ will return a new array with shape ``(2,1,3,4)``.
   [](const NodeAttrs& attrs){
     return std::vector<std::pair<int, int> >{{0, 0}};
   })
+.set_attr<nnvm::FInplaceIdentity>("FInplaceIdentity",
+  [](const NodeAttrs& attrs){
+    return std::vector<bool>{true};
+  })
 .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseNone{"_backward_copy"})
 .set_attr<FCompute>("FCompute<cpu>", IdentityCompute<cpu>)
 .add_argument("data", "NDArray-or-Symbol", "Source input")