azai91 commented on a change in pull request #11778: [MXNET-483] C++ tests for 
mkldnn convolution/deconvolution operator
URL: https://github.com/apache/incubator-mxnet/pull/11778#discussion_r224624098
 
 

 ##########
 File path: tests/cpp/operator/mkldnn.cc
 ##########
 @@ -515,14 +516,81 @@ OpAttrs GetConcatBackwardsOp(int num_args, int dim) {
 std::string CreateShapeString(int value, int dim) {
   std::stringstream ss;
   ss << "(";
-  for (int i = 0; i < dim; i++) {
+  for (size_t i = 0; i < dim; ++i) {
     ss << value;
     if (i != dim - 1) ss << ",";
   }
   ss << ")";
   return ss.str();
 }
 
+OpAttrs GetConvOp(int kernel, int num_filters, int dim, int stride, int pad) {
+  OpAttrs attrs;
+  attrs.attrs.op = Op::Get("Convolution");
+  attrs.num_inputs = 3;
+  attrs.num_outputs = 1;
+  attrs.attrs.dict.insert({"kernel" , CreateShapeString(kernel, dim)});
+  attrs.attrs.dict.insert({"num_filter" , std::to_string(num_filters)});
+  attrs.attrs.dict.insert({"stride" , CreateShapeString(stride, dim)});
+  attrs.attrs.dict.insert({"pad" , CreateShapeString(pad, dim)});
+  attrs.attrs.op->attr_parser(&attrs.attrs);
+  attrs.input_types = ArrayTypes::Normal |
+      ArrayTypes::MKLDNN |
+      ArrayTypes::NormalReshaped |
+      ArrayTypes::MKLDNNReshaped |
+      ArrayTypes::NormalReused |
+      ArrayTypes::MKLDNNReused |
+      ArrayTypes::NormalReshapedReused;
+  attrs.output_types = ArrayTypes::Normal |
+      ArrayTypes::MKLDNN |
+      ArrayTypes::NormalReshaped |
+      ArrayTypes::MKLDNNReshaped |
+      ArrayTypes::NormalReused |
+      ArrayTypes::MKLDNNReused |
+      ArrayTypes::NormalReshapedReused |
+      ArrayTypes::NormalReusedDiffDtype;
+  return attrs;
+}
+
+OpAttrs GetConvBackwardOp(int kernel, int num_filters, int dim, int stride, 
int pad) {
+  OpAttrs attrs;
+  attrs.attrs.op = Op::Get("_backward_Convolution");
+  attrs.num_inputs = 4;
+  attrs.num_outputs = 3;
+  attrs.attrs.dict.insert({"kernel" , CreateShapeString(kernel, dim)});
+  attrs.attrs.dict.insert({"num_filter" , std::to_string(num_filters)});
+  attrs.attrs.dict.insert({"stride" , CreateShapeString(stride, dim)});
+  attrs.attrs.dict.insert({"pad" , CreateShapeString(pad, dim)});
+  attrs.attrs.op->attr_parser(&attrs.attrs);
 
 Review comment:
   input and output are just specified in the forward operator. the output of 
the forward is the input of the backwards.

----------------------------------------------------------------
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

Reply via email to