tqchen commented on code in PR #19620:
URL: https://github.com/apache/tvm/pull/19620#discussion_r3312573658


##########
src/runtime/contrib/dnnl/dnnl_json_runtime.cc:
##########
@@ -49,6 +48,16 @@ namespace contrib {
 using namespace tvm::runtime;
 using namespace tvm::runtime::json;
 
+namespace {
+inline bool contains(const std::string& s, const std::string& sub) {
+  return s.find(sub) != std::string::npos;
+}
+inline bool contains_any(const std::string& s, const std::string& a, const 
std::string& b,
+                         const std::string& c) {
+  return contains(s, a) || contains(s, b) || contains(s, c);
+}

Review Comment:
   Done — applied in b37446d4c8. Replaced the fixed three-arg overload with a 
C++17 variadic template + fold expression.



##########
src/runtime/contrib/dnnl/dnnl_json_runtime.cc:
##########
@@ -250,31 +247,24 @@ class DNNLJSONRuntime : public JSONRuntimeBase {
     std::set<uint32_t> io_eid_set(run_arg_eid_.begin(), run_arg_eid_.end());
     tensor_registry_ = TensorRegistry(engine_, io_eid_set);
 
-    std::string conv_pat(".*conv[1-3]d.*");
-    std::string deconv_pat(".*deconv[1-3]d.*");
-    std::string conv_transpose_pat(".*conv[1-3]d_transpose.*");
-    std::string dense_pat(".*dense.*");
-    std::string max_pool_pat(".*max_pool[1-3]d");
-    std::string avg_pool_pat(".*avg_pool[1-3]d");
-
     // Build subgraph engine.
     for (size_t nid = 0; nid < nodes_.size(); ++nid) {
       const auto& node = nodes_[nid];
       if (node.GetOpType() == "kernel") {
         TVM_FFI_ICHECK_EQ(node.GetOpType(), "kernel");
         auto op_name = node.GetOpName();
-        if (tvm::runtime::regex_match(op_name, deconv_pat) ||
-            tvm::runtime::regex_match(op_name, conv_transpose_pat)) {
+        if (contains_any(op_name, "deconv1d", "deconv2d", "deconv3d") ||
+            contains_any(op_name, "conv1d_transpose", "conv2d_transpose", 
"conv3d_transpose")) {

Review Comment:
   Done — applied in b37446d4c8. Folded both contains_any calls into a single 
six-argument call; branch order preserved (deconv/conv_transpose check still 
precedes plain conv check).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to