optima2005 commented on a change in pull request #4418: [RUNTIME] Add cudnn 
conv3d
URL: https://github.com/apache/incubator-tvm/pull/4418#discussion_r352124471
 
 

 ##########
 File path: src/runtime/contrib/cudnn/conv_forward.cc
 ##########
 @@ -287,6 +355,91 @@ TVM_REGISTER_GLOBAL("tvm.contrib.cudnn.conv2d.find_algo")
   }
 
   ret[0] = best_algo;
+}
+
+
+TVM_REGISTER_GLOBAL("tvm.contrib.cudnn.conv.forward")
+.set_body([](TVMArgs args, TVMRetValue *ret) {
+  int mode = args[0];
+  int format = args[1];
+  int algo = args[2];
+  int dims = args[3];
+
+  Array<Expr> pads =  args[4];
+  Array<Expr> strides =  args[5];
+  Array<Expr> dilations =  args[6];
+
+  std::vector<int> pad_v(dims), stride_v(dims), dilation_v(dims);
+
+  for (auto &pad : pads) {
+    int i = 0;
+    pad_v[i++] = pad.as<IntImm>()->value;
+  }
+  for (auto &stride : strides) {
+    int i = 0;
+    pad_v[i++] = strides.as<IntImm>()->value;
+  }
+  for (auto &dilation : dilations) {
+    int i = 0;
+    pad_v[i++] = dilations.as<IntImm>()->value;
+  }
+
+  DLTensor* x = args[7];
+  DLTensor* w = args[8];
+  DLTensor* y = args[9];
+  std::string conv_dtype = args[10];
+
+  ConvolutionForward(mode, format, algo, pad_v, stride_v, dilation_v,
+                     x, w, y, conv_dtype);
+});
+
+
+TVM_REGISTER_GLOBAL("tvm.contrib.cudnn.conv.output_shape")
+.set_body([](TVMArgs args, TVMRetValue *ret) {
+  int format = args[0];
+  int dims = args[1];
+  int* pad = static_cast<int*>(static_cast<void*>(args[2]));
+  int* stride = static_cast<int*>(static_cast<void*>(args[3]));
+  int* dilation = static_cast<int*>(static_cast<void*>(args[4]));
+  int* x_dim = static_cast<int*>(static_cast<void*>(args[5]));
+  int* w_dim = static_cast<int*>(static_cast<void*>(args[6]));
+  std::vector<int> pad_v(pad, pad + dims);
+  std::vector<int> stride_v(stride, stride + dims);
+  std::vector<int> dilation_v(dilation, dilation + dims);
+  std::vector<int> x_dim_v(x_dim, x_dim + dims + 2);
+  std::vector<int> w_dim_v(w_dim, w_dim + dims + 2);
+
 
 Review comment:
   Originally I only use vector to handle the different tuple size for 2d and 
3d.  After we have unified all those 2d, 3d stuff, they replace most of the C 
style arrays. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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