You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/07/13 20:39:24 UTC
[GitHub] eric-haibin-lin commented on a change in pull request #11587:
[MXNET-378] Adding depth_to_space and space_to_depth operator(Updated)
eric-haibin-lin commented on a change in pull request #11587: [MXNET-378] Adding depth_to_space and space_to_depth operator(Updated)
URL: https://github.com/apache/incubator-mxnet/pull/11587#discussion_r202466025
##########
File path: src/operator/tensor/matrix_op.cc
##########
@@ -908,5 +909,100 @@ NNVM_REGISTER_OP(_backward_squeeze)
.set_attr<nnvm::TIsBackward>("TIsBackward", true)
.set_attr<FCompute>("FCompute<cpu>", UnaryOp::IdentityCompute<cpu>);
+NNVM_REGISTER_OP(depth_to_space)
+.describe(R"code(This operators implements the depthToSpace function:
+
+.. math::
+
+ f(x, block) = \tilde{x}
+
+where :math:`x` is an input tensor of shape [N,C,H,W] and :math:`\tilde{x}` is the output tensor of shape :math:`[N, C/(block^2), H*block, W*block]`
+
+Example::
+
+ x = [[[[0, 1, 2],
+ [3, 4, 5]],
+ [[6, 7, 8],
+ [9, 10, 11]],
+ [[12, 13, 14],
+ [15, 16, 17]],
+ [[18, 19, 20],
+ [21, 22, 23]]]]
+
+ depth_to_space(x, 2) = [[[[0, 6, 1, 7, 2, 8],
+ [12, 18, 13, 19, 14, 20],
+ [3, 9, 4, 10, 5, 11],
+ [15, 21, 16, 22, 17, 23]]]]
+)code" ADD_FILELINE)
+.set_attr_parser(ParamParser<DepthToSpaceParam>)
+.set_num_inputs(1)
+.set_num_outputs(1)
+.set_attr<nnvm::FListInputNames>("FListInputNames",
+ [](const NodeAttrs& attrs) {
+ return std::vector<std::string>{"data"};
+ })
+.set_attr<nnvm::FInferShape>("FInferShape", DepthToSpaceOpShape)
+.set_attr<nnvm::FInferType>("FInferType", DepthToSpaceOpType)
+.set_attr<FCompute>("FCompute<cpu>", DepthToSpaceOpForward<cpu>)
+.set_attr<FResourceRequest>("FResourceRequest",
+ [](const NodeAttrs& n) {
+ return std::vector<ResourceRequest>{ResourceRequest::kTempSpace};
+})
+.set_attr<nnvm::FInplaceOption>("FInplaceOption",
Review comment:
Does this operator really support inplace optimization? If you register this, in forward pass the executor will try to allocate NDArray for both input and output
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services