haojin2 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_r200792221
##########
File path: src/operator/tensor/matrix_op-inl.h
##########
@@ -2158,6 +2158,285 @@ inline bool SqueezeShape(const nnvm::NodeAttrs& attrs,
return true;
}
+
+struct DepthToSpaceParam : public dmlc::Parameter<DepthToSpaceParam> {
+ int blockSize;
+ DMLC_DECLARE_PARAMETER(DepthToSpaceParam) {
+ DMLC_DECLARE_FIELD(blockSize)
+ .describe("The size of chunks that need to be taken from depth and
spread across to the "
+ "shape dimension of the tensor");
+ }
+};
+
+inline bool DepthToSpaceOpShape(const nnvm::NodeAttrs& attrs,
+ std::vector<TShape>* in_attrs,
+ std::vector<TShape>* out_attrs) {
+ const DepthToSpaceParam& param = nnvm::get<DepthToSpaceParam>(attrs.parsed);
+ CHECK_EQ(in_attrs->size(), 1U);
+ CHECK_EQ(out_attrs->size(), 1U);
+ CHECK_EQ(in_attrs->at(0).ndim(), 4) << "Operation Depth To Space requires
exactly 4D tensor";
+
+ TShape expected_out(in_attrs->at(0).ndim());
+
+ TShape& in_shape = in_attrs->at(0);
+ int block = param.blockSize;
+ CHECK_NE(in_shape[1], 0)
+ << "Depth dimension:1 cannot be 0";
+ CHECK_EQ(in_shape[1]%(block*block), 0)
+ << "Cannot perform Depth To Space operation on the specified tensor. "
+ "Dimension:1(depth dimension) should be a multiple of 'block^2' ";
Review comment:
Alignment
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services