You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/26 20:02:11 UTC

[GitHub] [tvm] comaniac commented on a change in pull request #9127: [BYOC] support arbitrary input dims for add/mul/relu of dnnl c_src codegen

comaniac commented on a change in pull request #9127:
URL: https://github.com/apache/tvm/pull/9127#discussion_r716253062



##########
File path: src/relay/backend/contrib/dnnl/codegen.cc
##########
@@ -98,12 +107,7 @@ std::vector<std::string> Dense(const CallNode* call) {
 std::vector<std::string> Relu(const CallNode* call) {
   std::vector<std::string> args;
   auto ishape = GetShape(call->args[0]->checked_type());
-
-  // Args: N, C, H, W
-  for (auto s : ishape) {
-    args.push_back(std::to_string(s));
-  }
-

Review comment:
       Better to keep the layout comment.

##########
File path: src/relay/backend/contrib/dnnl/codegen.cc
##########
@@ -126,12 +130,16 @@ std::vector<std::string> BatchNorm(const CallNode* call) {
 std::vector<std::string> Add(const CallNode* call) {
   std::vector<std::string> args;
   auto ishape = GetShape(call->args[0]->checked_type());
+  args.push_back("0");
+  args.push_back(GetShapeString(ishape));
+  return args;
+}
 
-  // Args: H, W
-  for (auto s : ishape) {
-    args.push_back(std::to_string(s));
-  }
-
+std::vector<std::string> Multiply(const CallNode* call) {

Review comment:
       Better to comment what args are.

##########
File path: src/runtime/contrib/dnnl/dnnl.cc
##########
@@ -44,6 +44,32 @@ typedef struct {
   void** data;
 } DnnlPackedArgs;
 
+inline dnnl::memory::desc GenDNNLMemDescByShape(const dnnl::memory::dims& shape,
+                                                memory::data_type dtype) {
+  using tag = memory::format_tag;
+
+  dnnl::memory::desc data_md;
+
+  switch (shape.size()) {
+    case 2:
+      data_md = dnnl::memory::desc({shape, dtype, tag::ab});
+      break;
+    case 3:
+      data_md = dnnl::memory::desc({shape, dtype, tag::abc});
+      break;
+    case 4:
+      data_md = dnnl::memory::desc({shape, dtype, tag::abcd});
+      break;
+    case 5:
+      data_md = dnnl::memory::desc({shape, dtype, tag::abcde});
+      break;
+    default:
+      assert(true);

Review comment:
       ```suggestion
         LOG(FATAL) << "message";
   ```
   




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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org