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/01/24 23:36:05 UTC
[incubator-mxnet] branch master updated: Bugfix: kAddTo support for
swap_axes. (#9541)
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 5f9dd2c Bugfix: kAddTo support for swap_axes. (#9541)
5f9dd2c is described below
commit 5f9dd2c9f18274376b13d29b71868599ebcd9a90
Author: Tobias Domhan <td...@gmail.com>
AuthorDate: Thu Jan 25 00:36:01 2018 +0100
Bugfix: kAddTo support for swap_axes. (#9541)
Co-authored-by: Asmus Hetzel <ah...@amazon.com>.
---
src/operator/swapaxis-inl.h | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/operator/swapaxis-inl.h b/src/operator/swapaxis-inl.h
index e4bdfd5..7b0e2fa 100644
--- a/src/operator/swapaxis-inl.h
+++ b/src/operator/swapaxis-inl.h
@@ -101,8 +101,9 @@ class SwapAxisOp : public Operator {
}
void SwapAxis(mshadow::Stream<xpu> *s,
- const std::vector<TBlob> &in_data,
- const std::vector<TBlob> &out_data) {
+ const std::vector<TBlob> &in_data,
+ const std::vector<TBlob> &out_data,
+ const std::vector<OpReqType> &req) {
using namespace mshadow;
using namespace mshadow::expr;
uint32_t dim1 = param_.dim1;
@@ -110,6 +111,7 @@ class SwapAxisOp : public Operator {
TBlob data_in = in_data[swapaxisenum::kData];
TBlob data_out = out_data[swapaxisenum::kData];
+ OpReqType out_req = req[swapaxisenum::kData];
TShape shape_in = data_in.shape_;
TShape shape_out = data_out.shape_;
@@ -125,7 +127,11 @@ class SwapAxisOp : public Operator {
Tensor<xpu, 5, DType> inter_data_out = data_out.get_with_shape<xpu, 5, DType>(inter_shape2, s);
- inter_data_out = swapaxis<3, 1>(inter_data_in);
+ if (out_req == kAddTo) {
+ inter_data_out += swapaxis<3, 1>(inter_data_in);
+ } else {
+ inter_data_out = swapaxis<3, 1>(inter_data_in);
+ }
}
virtual void Forward(const OpContext &ctx,
@@ -136,7 +142,7 @@ class SwapAxisOp : public Operator {
using namespace mshadow;
Stream<xpu> *s = ctx.get_stream<xpu>();
- SwapAxis(s, in_data, out_data);
+ SwapAxis(s, in_data, out_data, req);
}
virtual void Backward(const OpContext &ctx,
@@ -149,7 +155,7 @@ class SwapAxisOp : public Operator {
using namespace mshadow;
Stream<xpu> *s = ctx.get_stream<xpu>();
- SwapAxis(s, out_grad, in_grad);
+ SwapAxis(s, out_grad, in_grad, req);
}
SwapAxisParam param_;
--
To stop receiving notification emails like this one, please contact
jxie@apache.org.